Jump to content

Fastest way to send multiple HTTP requests


Recommended Posts

Hello, 

I have A simple question about http request. What would be the fastest way to send mupltiple http request at the same time with autoit? The only way i figured  out was to to start multiple processes. This way works fine but its not really a good way. What user would like to see 15 processes running in the background at the same time. I know multithread is also not available in autoit.

Edited by paradox109
Link to comment
Share on other sites

Example multi request 10 pages website:

Local $Thread = 10
Local $oWH[$Thread]
Local $ThreadCompleted[$Thread]
Local $CheckCompleted = 0
Local $AsyncMode = True

For $i = 0 To $Thread - 1
    $oWH[$i] = ObjCreate('WinHttp.WinHttpRequest.5.1')
    $oWH[$i].Open('GET', 'http://autoitvn.com/forums/thao-luan-hoi-dap/page-' & ($i + 1), $AsyncMode)
    $oWH[$i].Send()
Next

Do
    For $i = 0 To $Thread - 1
        If $ThreadCompleted[$i] = 0 And $oWH[$i].WaitForResponse(0) = True Then ;$ThreadCompleted[$i] variable condition to prevent loop result
            ConsoleWrite('>Page ' & $i & ' completed:' & @CRLF & $oWH[$i].GetAllResponseHeaders & @CRLF)
            $ThreadCompleted[$i] = 1
            $CheckCompleted += 1
        EndIf
    Next
Until $CheckCompleted = $Thread

MsgBox(0, 'Hi', 'Completed')

This method works very fast and do not use as much CPU and RAM resources as multi process

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

×
×
  • Create New...