Sign in to follow this  
Followers 0
GtaSpider

InetGetSource with Post string

26 posts in this topic

#1 ·  Posted (edited)

Hello everyone Posted Image

You all know the function on Inet.au3 "_INetGetSource". The bad is: It's need a dll and you can not send a Post string (execpt u send manually a header)

So ive created a function (_InetGetSourcePost, very creative, like i am :) ) with witch u can Download the Sourcecode with Post sending.

Youll receive the BackHeader and the Sourcecode in an Array.

Ok, sorry for my bad english, but i hope u like my "autoish" :(

Function:

#include-once


;===============================================================================
;
; Function Name:    _INetGetSourcePost()
; Description:      Gets the source from an URL without writing a temp file and you can send a Post.
; Parameter(s):     $sURL = The URL of the site.
;              $sPost = The Post to send
; Requirement(s):   -
; Return Value(s):  On Success - Return a array with $aReturn[0] = Backheader and $aReturn[1] = Sourcecode
;                   On Failure - 0  and sets @ERROR
;               @error = 1: Post or URL is nothing
;               @error = 2: Error by RegularExpression
;               @error = 3: $sHost or $sHttp1 is nothing
;               @error = 4: Can not get IP of Host
;               @error = 5: Can not connect to host
;               @error = 6: Nothing can be send
;               @error = 7: Connection abborted while receiving
; Author(s):        GtaSpider
;
;===============================================================================



Func _INetGetSourcePost($sURL, $sPost)
    Local $iSocket, $sHeader, $sRecv, $iIP, $sHost, $aRegExp, $sHttp1,$iErr,$iSend,$aReturn[2]
    
    If $sURL = '' Or $sPost = '' Then Return SetError(1, 0, 0) 
    
    If StringLeft($sURL, 7) <> 'http://' And StringLeft($sURL, 8) <> 'https://' Then $sURL = "http://" & $sURL
    If StringRight($sURL, 1) <> "/" Then $sURL &= "/"
    
    $aRegExp = StringRegExp($sURL, "http?://(.*?)/", 3)
    If @error Then Return SetError(2, 0, 0)
    
    $sHost = $aRegExp[0]
    If $sHost = '' Then Return SetError(3, 0, 0)
    
    $sHttp1 = StringTrimLeft($sURL,StringInStr($sURL,"/",-1,3)-1)
    If $sHttp1 = '' Then Return SetError(3, 0, 0)
    
    
    $sHeader = "POST " & $sHttp1 & " HTTP/1.1" & @CRLF & _
            "Host: " & $sHost & @CRLF & _
            "User-Agent: AutoIt v3" & @CRLF & _
            "Content-Length: " & StringLen($sPost) & @CRLF & @CRLF & $sPost
            
            
    TCPStartup() ;If not already done
    $iIP = TCPNameToIP($sHost)
    If $iIP = '' Or StringInStr($iIP, ".") = 0 Then Return SetError(4, 0, 0)
    $iSocket = TCPConnect($iIP, 80)
    If @error Or $iSocket < 0 Then Return SetError(5, 0, 0)
    
    $iSend = TCPSend($iSocket, $sHeader)
    If @error Or $iSend < 1 Then Return SetError(6, 0, 0)
    
    
    While 1
        $sRecv = TCPRecv($iSocket, 1024)
        $iErr = @error
        If $sRecv <> '' Then
            While 1
                $sRecv &= TCPRecv($iSocket, 1024)
                If @error Then ExitLoop 2
            WEnd
        EndIf
        If $iErr Then Return SetError(7,0,0)
    WEnd
    
    $aReturn[0] = StringLeft($sRecv,StringInStr($sRecv,@CRLF&@CRLF)-1)
    $aReturn[1] = StringTrimLeft($sRecv,StringLen($aReturn[0])+4)
    Return $aReturn
EndFunc   ;==>_INetGetSourcePostoÝ÷ ØLZ^jëh×6#include <INETv2.au3>
;by GtaSpider


SplashTextOn("","Downloading...",200,20,-1,-1,1)
$aSource = _INetGetSourcePost("http://rs255.rapidshare.com/files/110695594/cardr.rar","dl.start=Free")
If @error Then Exit MsgBox(16,"","Error: "&@error)
FileWrite("TestFile.html",$aSource[1])
RunWait('"' & @ComSpec & '" /c "'&@ScriptDir&'\TestFile.html"', '', @SW_HIDE)
SplashOff()

In attachment there are the Include and the Expample

Your Spider

Edit: HotFix

INETv2.zip

Edited by GtaSpider

www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites



While 1

While 1

ExitLoop

WEnd

ExitLoop

WEnd

Can be shortened to

While 1

While 1

Exitloop 2

WEnd

WEnd

Share this post


Link to post
Share on other sites

Hello

Yeah, ur rigth... But i like the old natural autoit coding :)

On next Upload ill fix that, thank you

Your Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

seems cool, Although I don't know what post or something is..

Share this post


Link to post
Share on other sites

Hi

With post u can receive informations by php.

e.g. usernames or passwords.. so u can make an autologin or smth else..

Your Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

Cool!

Share this post


Link to post
Share on other sites

Wow~!!!

Share this post


Link to post
Share on other sites

Hi

Thanks :)

Here is a short example, what $_POST @ php is: PHP POST

Your Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

SUPERFANTASTIC!!! THANKS!!!!


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites

Wow, it's better then I thought!

Share this post


Link to post
Share on other sites

Hi

Nice idea, James :) There are a lot of applications to use for.

It can do many things, what the IE.au3 can do, but a lot of faster because the IE doesnt have to load.

@ludocus: isn't it? Thanks :(

your Spider

sry4my bad engl


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

not work for me :)

_INetGetSourcePost("http://www....../page.php","var1=val1&var2=val2")


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites

Hi

Wich error return the Function?

Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

And what about

Accept-Encoding: compress, gzip

header ? is there a pure stream decompression ?

Share this post


Link to post
Share on other sites

no error return. i read the first post. i cant send string? need dll? what dll?

thanks :)


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites

Hi Cyber!

No, you dont need a dll or somthing like this. Does the Example work by you?

Your Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

Your example work :)

dl.start is the name of variable?


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Hi

No, dl.start is the name.

Look at the Source:

<tr><td><b>Bitte den Download-Typ w&auml;hlen:</td><td align="center"><input type="submit" name="dl.start" value="PREMIUM"></td><td align="center"><input type="submit" name="dl.start" value="Free"></td></tr>

Here you see, if you push the "Free" button on http://rs255.rapidshare.com/files/110695594/cardr.rar , he sending POST with name dl.start and Value free (name=Value in this example dl.start=Free)

Your Spider

Edited by GtaSpider

www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

ok :)

I try to get with PHP:

echo $HTTP_POST[$test];

and your program, but not arrive the return :)


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

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