Jump to content

WinHttp SetProxy problem


Recommended Posts

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Inet.au3>
#include <String.au3>
#include <WinHttp.au3>
Global $baselink = "http://www.ip.biz.tr"
$Form1_1 = GUICreate("Form1", 450, 280)
$KQ = GUICtrlCreateEdit("", 32, 32, 185, 241)
GUICtrlSetData(-1, "")
$Run = GUICtrlCreateButton("Run", 320, 16, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Run
            Get()

    EndSwitch
WEnd

Func Get()
$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
    $oHTTP.open("GET", $baselink, False)
     $oHttp.SetProxy(2,"189.28.166.79:80")
    $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
    $oHTTP.SetRequestHeader("Referrer", $baselink)
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    $search = "/"
    $results = ""
    for $i=0 to 2 step 2
        $currentlink = $baselink
        $source = _InetGetSource($currentlink)
        $eachlink = _StringBetween($source,'class="fg','</span')
        if isArray($eachlink) then
            for $z=0 to ubound($eachlink)-1
                If StringInStr($eachlink[$z], "-blue") Then
                    $Link = $eachlink[$z]
                    $results &= $Link&@CRLF
                    GUICtrlSetData ($KQ, $results)
                EndIf
            next
        endif
    Sleep(100)
    next
EndFunc

 

Link to comment
Share on other sites

Try:

#include <Inet.au3>
#include <String.au3>

Global $baselink = "http://www.ip.biz.tr"

HttpSetProxy(2, "189.28.166.79:80")

$source = _INetGetSource($baselink)
$eachlink = _StringBetween($source, '<span class="fg-blue">', '</span>')
If IsArray($eachlink) Then MsgBox(32, "Check IP", "CurrenIP: " & $eachlink[0] & @CRLF)
;~ MsgBox(32, "Check IP", "CurrenIP: " & _GetIP() & @CRLF)

 

Regards,
 

Link to comment
Share on other sites

Thank you
Is this code written right?

#include <Inet.au3>
#include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $baselink = "http://www.ip.biz.tr"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 452, 282, 33, 105)
$Edit1 = GUICtrlCreateEdit("", 32, 32, 185, 241)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Run", 320, 16, 75, 25)
$Edit2 = GUICtrlCreateEdit("", 232, 88, 169, 177)
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $aproxyread = StringSplit(GUICtrlRead($Edit1), @CR)
For $aproxyadd = 1 To UBound($aproxyread) - 1
    Sleep(100)
        HttpSetProxy(2, $aproxyread[$aproxyadd])
$source = _INetGetSource($baselink)
$eachlink = _StringBetween($source, '<span class="fg-blue">', '</span>')
If IsArray($eachlink) Then GUICtrlSetData ($Edit2, $aproxyadd & @CRLF & $aproxyread[$aproxyadd]& @CRLF & $eachlink[0])
Next
    EndSwitch
WEnd

 

Link to comment
Share on other sites

Your script run good !
You get ip with AutoIt functions will be faster:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /pe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Inet.au3>
#include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $baselink = "http://www.ip.biz.tr"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 452, 282, 33, 105)
$Edit1 = GUICtrlCreateEdit("", 32, 32, 185, 241)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Run", 320, 16, 75, 25)
$Edit2 = GUICtrlCreateEdit("", 232, 88, 169, 177)
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $aproxyread = StringSplit(GUICtrlRead($Edit1), @CR)
            For $aproxyadd = 1 To UBound($aproxyread) - 1
                Sleep(100)
                HttpSetProxy(2, $aproxyread[$aproxyadd])
;~              $source = _INetGetSource($baselink)
;~              $eachlink = _StringBetween($source, '<span class="fg-blue">', '</span>')
;~              If IsArray($eachlink) Then GUICtrlSetData($Edit2, $aproxyadd & @CRLF & $aproxyread[$aproxyadd] & @CRLF & $eachlink[0])
                GUICtrlSetData($Edit2, "Proxy: " & $aproxyread[$aproxyadd] & @CRLF & "CurIP: " & _IPGet())
            Next
    EndSwitch
WEnd

Func _IPGet()
    Local Const $GETIP_TIMER = 3000
    Local Static $hTimer = 0
    Local Static $sLastIP = 0
    If TimerDiff($hTimer) < $GETIP_TIMER And Not $sLastIP Then
        Return SetExtended(1, $sLastIP)
    EndIf
    Local $aGetIPURL[] = ["http://bot.whatismyipaddress.com", "http://www.myexternalip.com/raw", "http://checkip.dyndns.org"], $aReturn = 0, $sReturn = ""
    For $i = 0 To UBound($aGetIPURL) - 1
        $sReturn = InetRead($aGetIPURL[$i])
        If @error Or $sReturn == "" Then ContinueLoop
        $aReturn = StringRegExp(BinaryToString($sReturn), "((?:\d{1,3}\.){3}\d{1,3})", 3)
        If Not @error Then
            $sReturn = $aReturn[0]
            ExitLoop
        EndIf
        $sReturn = ""
    Next
    $hTimer = TimerInit()
    $sLastIP = $sReturn
    If $sReturn == "" Then Return SetError(1, 0, -1)
    Return $sReturn
EndFunc   ;==>_IPGet

 

Regards,
 

Link to comment
Share on other sites

guıctrlsetdat to ($ Edit2 I want _GET with the for loop

Please help how to do

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /pe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Inet.au3>
#include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $baselink = "http://www.ip.biz.tr"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 452, 282, 33, 105)
$Edit1 = GUICtrlCreateEdit("", 32, 32, 185, 241)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Run", 320, 16, 75, 25)
$Edit2 = GUICtrlCreateEdit("", 232, 88, 169, 177)
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1

            $aproxyread = StringSplit(GUICtrlRead($Edit1), @CR)

            For $aproxyadd = 1 To UBound($aproxyread) - 1
                Sleep(100)
                HttpSetProxy(2, $aproxyread[$aproxyadd])
;~              $source = _INetGetSource($baselink)
;~              $eachlink = _StringBetween($source, '<span class="fg-blue">', '</span>')
;~              If IsArray($eachlink) Then GUICtrlSetData($Edit2, $aproxyadd & @CRLF & $aproxyread[$aproxyadd] & @CRLF & $eachlink[0])
 For $ipget = 0 To UBound(_IPGet) - 1
               GUICtrlSetData($Edit2, "Proxy: " & $aproxyread[$aproxyadd] & @CRLF & "CurIP: " & $ipget[_IPGet()])
 Next
  Sleep(100)
Next

    EndSwitch
WEnd

Func _IPGet()
    Local Const $GETIP_TIMER = 3000
    Local Static $hTimer = 0
    Local Static $sLastIP = 0
    If TimerDiff($hTimer) < $GETIP_TIMER And Not $sLastIP Then
        Return SetExtended(1, $sLastIP)
    EndIf
    Local $aGetIPURL[] = ["http://bot.whatismyipaddress.com", "http://www.myexternalip.com/raw", "http://checkip.dyndns.org"], $aReturn = 0, $sReturn = ""
    For $i = 0 To UBound($aGetIPURL) - 1
        $sReturn = InetRead($aGetIPURL[$i])
        If @error Or $sReturn == "" Then ContinueLoop
        $aReturn = StringRegExp(BinaryToString($sReturn), "((?:\d{1,3}\.){3}\d{1,3})", 3)
        If Not @error Then
            $sReturn = $aReturn[0]
            ExitLoop
        EndIf
        $sReturn = ""
    Next
    $hTimer = TimerInit()
    $sLastIP = $sReturn
    If $sReturn == "" Then Return SetError(1, 0, -1)
    Return $sReturn

EndFunc   ;==>_IPGet

 

or should be like this

Line :48

 For $i = 1 To UBound($aGetIPURL) - 1

Edited by youtuber
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...