Jump to content

Is there a stable function for curl on a web page, with proxy, in autoit?


Recommended Posts

Is there a stable function for curl on a web page, with proxy, in autoit?

I tried the classic with BinaryToString (InetRead ($ url, 1), 4) 

but it doesn't work if the page loads too slowly...

 

Then I tried WinHttp.WinHttpRequest.5.1, but it has moments when it works, and moments when it doesn't work. It doesn't look stable.

 

If there is a stable function through which I can read a web page, using proxy, let me know.

 

my code:

Func InetRead2($url)


    $row_proxy_random = $proxy_file_array[Random(1, $proxy_file_total_lines, 1)]
    $split_details_proxi = StringSplit($row_proxy_random, ":", 1)

    $proxy_ip = $split_details_proxi[1]
    $proxy_port = $split_details_proxi[2]
    $proxy_user = $split_details_proxi[3]
    $proxy_pass = $split_details_proxi[4]
    $proxy_act = $proxy_ip & ":" & $proxy_port


    $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")

    $oHttp.Open("GET", $url, False)
    $oHttp.SetTimeouts(300000, 600000, 300000, 300000)

    $oHttp.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36")
    $oHttp.SetRequestHeader("Referer", $url)


    ConsoleWrite(@CRLF & $proxy_act)
    $oHttp.SetProxy(2, $proxy_act, "")
    $oHttp.SetCredentials($proxy_user, $proxy_pass, 1)

    $oHttp.Option(9) = 128 ;512
    $oHttp.Send("")
    If @error Then Return SetError(5, "", "")

    $oHttp.WaitForResponse()

    $HTMLSource = $oHttp.Responsetext

    Return $HTMLSource

    $oHttp.Close
EndFunc   ;==>InetRead2

 

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...