Sign in to follow this  
Followers 0
Irongeek

InetGet and referer

4 posts in this topic

#1 ·  Posted (edited)

When you use InetGet is there a way to set the agent? I'd like to write a front end for Wigle and it would help because it changes output depending on the agent. Thanks.

/edit: Oops, I mean set the agent.

Edited by Irongeek

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#cs
GET /myfiles/game/game.php?user=nfwu HTTP/1.1
User-Agent: AutoIt v3
Host: zerocool60544.t35.com
Cache-Control: no-cache
#ce
Func OnAutoItStart()
    TCPStartup()
EndFunc
Func _INetGet_Mod($host, $request, $useragent)
    $socket = TCPConnect( TCPNameToIP($host), 80 )
    If $socket = -1 Then Return "Error"
    TCPSend($socket, _
            "GET " & $request & " HTTP/1.1" & @CRLF & _
            "User-Agent: " & $useragent    & @CRLF & _
            "Host: " & $host               & @CRLF & _
            "Cache-Control: no-cache"      & @CRLF & _
            @CRLF )
    Local $recv
    Do
        $recv &= TCPRecv($socket,2048)
    Until @error
    Return $recv
EndFunc

Sample Usage:

_INetGet_Mod("www.autoitscript.com", "/forum/index.php", "AutoIt v3")

#)

Edited by nfwu

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That code will work, but the output will be the raw packets as opposed to the actual data of the response. In the case of a chunked response, it would be a real pain to write a parser...

... a pain that I already went through, so you shouldn't have to! I recommend checking out my HTTP UDF's - one of the features is that you can set the User-Agent.

Edited by OverloadUT

Share this post


Link to post
Share on other sites

Thanks guys.

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