RyukShini Posted June 28, 2016 Posted June 28, 2016 I am coding a country specific IP checker with a buddy, he made the website/api and I am coding a client to run through IPs. i split my IPs so it doesn't read the port instead of IP:PORT just IP, however after reading through every IP I need to add all ports back in their right place again so it becomes IP:PORT again, but this part made my head spin a bit. Any help is highly appreciated! Thanks in advance. expandcollapse popup#include <ColorConstants.au3> ; Including required files #include <GUIConstantsEx.au3> #include <file.au3> #include <Array.au3> #include <string.au3> #include <StringConstants.au3> Example() Func Example() While 1 Local $ip Local $ips = "18k.txt" ;sets file path Local $strFileContents = FileRead($ips) $Arrayips = StringRegExp($strFileContents,'((?:\d+)(?:\.\d+){3})',3) For $i = 1 To UBound($Arrayips) - 1 ; Creating the object $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://mysite:8080/json/" & $Arrayips[$i], False) ; Post url ; Header data > $oHTTP.SetRequestHeader("Host", "mysite.xyz:8080") $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0") $oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") $oHTTP.SetRequestHeader("Accept-Language", "en-US,en;q=0.5") $oHTTP.SetRequestHeader("DNT", "1") $oHTTP.SetRequestHeader("Connection", "keep-alive") $oHTTP.SetRequestHeader("Cache-Control", "max-age=0") ; Header data < ; Performing the Request $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode <> 200 then MsgBox(4096, "Response code", $oStatusCode) ExitLoop EndIf $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists FileWrite($file, $oReceived) $read = FileRead("Received.html") ;read fil if StringInStr($read, '"US",') Then FileWrite("output.txt", $Arrayips[$i] & @CRLF) Else ContinueLoop EndIf ;Sends the post data with the given details Next WEnd EndFunc ;==>Example
jvds Posted June 28, 2016 Posted June 28, 2016 when you extract the ips to an array extract the ports also to a diferent array, then after you write the ips write the ports FileWrite("output.txt", $Arrayips[$i] &':'& $Arrayports[$i] @CRLF)
RyukShini Posted June 29, 2016 Author Posted June 29, 2016 10 hours ago, jvds said: when you extract the ips to an array extract the ports also to a diferent array, then after you write the ips write the ports FileWrite("output.txt", $Arrayips[$i] &':'& $Arrayports[$i] @CRLF) Oh yea makes sense. Will try it out asap, thanks a lot!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now