Sign in to follow this  
Followers 0
DTheory

winhttp action fail

2 posts in this topic

Hello everyone, i recently started using autoit so i'm pretty nub and i'm going to ask a _maybe_ nub question

I made this script which reads the source of a webpage after sending some info through a POST string:

;//Open
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", $address, true)

;//Request
$oHTTP.SetRequestHeader("Referer", $address)
$oHTTP.SetRequestHeader("Accept-Languag", "it")
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)")
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.SetRequestHeader("Host", $host)
$oHTTP.SetRequestHeader("Content-Length", "42")
$oHTTP.SetRequestHeader("Connection", "Keep-Alive")
$oHTTP.SetRequestHeader("Cookie", $cookiesend)
$oHTTP.Send($send)

;//Answer
$HTMLSource = $oHTTP.Responsetext

Well, everything works properly for some pages, but for other pages it says:

: ==> The requested action with this object has failed.:

$HTMLSource = $oHTTP.Responsetext

$HTMLSource = $oHTTP.Responsetext^ ERROR

The only one things that changes in the responses between the first pages i tried to open (succesfully) and the other pages is the charset:

Working: Content-Type: text/html; charset=utf-8

Not working: Content-Type: text/html; charset=utf8

My questions are:

-is this the 'difference' that gives the 'fail' error?

-is there a way to solve the problem? (maybe converting from utf8 => utf-8?)

Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Solved using $ohttp.responseBODY instead of TEXT, thx anyway :unsure:

Edited by DTheory

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0