Jump to content

How To Set Referer & UserAgent


davida2
 Share

Recommended Posts

I am new to Autoit. I don't know how I haven't found it long ago. I have used other scripting languages, but am just getting started here. The forum looks like a very helpful place, so I am hoping you guys can give a newbie some direction.

I am writing a bot to loop through website pages changing proxies while I do (which I have working). I would also like to change the referer and useragent. In searching around, I found info like this post...which shows how to set the referer.

I also found this code somewhere (don't remember where)...

$oIE.Navigate2("http://www.whatsmyua.info/", Default, Default, Default, @CRLF & _
        "Accept-Charset: utf-8" & @CRLF & _
        "Accept-Encoding: gzip, deflate" & @CRLF & _
        "Accept-Language: en-US" & @CRLF & _
        "Connection: keep-alive" & @CRLF & _
        "Cookie: $Version=1; Skin=new;" & @CRLF & _
        "Content-Type: application/x-www-form-urlencoded" & @CRLF & _
        "Date: Tue, 15 Nov 1994 08:12:31 GMT" & @CRLF & _
        "Referer: http://www.bing.com" & @CRLF & _
         "User-Agent: Test UserAgent 1.0" & @CRLF & _
        "TE: trailers, deflate" & @CRLF & _
        "Referer: http://google.com" & @CRLF & _
        "User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;  Lumia 520)" & @CRLF & _
        "X-Requested-With: XMLHttpRequest" & @CRLF & _
        "Front-End-Https: on" & @CRLF & _
        "Proxy-Connection: keep-alive" & @CRLF & _
        "Access-Control-Allow-Origin: *" & @CRLF & _
        "Accept-Patch: text/example;charset=utf-8" & @CRLF & _
        "Allow: GET, HEAD" & @CRLF & _
        "Status: 200 OK")

...and they seem to work fine. But, like I mentioned, I would like to be able to change the referer & useragent (& the URL). Is there some way to change this code to use variables to do this? I have tried code like this and it doesn't seem to work...

local $sURL = "http://google.com"
local $sReferer = "Referer: http://bing.com"
local $sUserAgent = "User-Agent: My Test UA"
$oIE.Navigate2($sURL, Default, Default, Default, @CRLF & _
            $sReferer & @CRLF & _
            $sUserAgent)

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...