Jump to content
Sign in to follow this  
RyukShini

After runnning through array - add ports to IPs

Recommended Posts

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.

#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

 

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites
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!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By nooneclose
      I need to dynamically resize my 2d array while looping. 
      I know this code:
      ReDim $rArray[UBound($rArray) + 1] works for the rows, however, I also need to increase the columns. How would i go about increasing both rows and columns while looping? 
    • By argumentum
      In the ZIP is the code and the compiled script.
      This is yet another ping the LAN utility.
      Is quite fast, as gathering the info. is forked.
      The Save Note, saves a note for the given MAC ( you may find it handy )
      The Save MACs, saves the listview to an INI file that can be later use for the WakeOnLAN
      Right click will bring a context menu to do stuff. DClick will refresh the Ping.
      That's it. Comes in handy to have in the USB toolbox  
    • By Zaoka
      Hi guys
      Need little help with filtering.
      I'm trying to filter specific weeks from power pivot table using this code recorded with Excel VBA :
       
      #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\....\Orders.xlsb") $oWorkbook.PivotTables("PivotTable1").PivotFields( _ "[Report 2].[Week].[Week]").VisibleItemsList = Array( _ "[Report 2].[Week].&[10]", "[Report 2].[Week].&[11]", _ "[Report 2].[Week].&[12]", "[Report 2].[Week].&[13]", _ "[Report 2].[Week].&[14]", "[Report 2].[Week].&[15]") But get error
      error: Array(): undefined function. Not sure how to resolve this.
    • By LxP
      I'm trying to pass a nested array to a function, such that the function alters the inner array.
      I was surprised to find that this minimal reproducible example, despite its use of ByRef, seems to pass a copy of the inner array to the function:
      #include <Array.au3> ; a boring old array Local $aInnerArray[5] = [1, 2, 3, 4, 5] ; a one-element array containing a reference to the other array Local $aOuterArray[1] = [$aInnerArray] ; intention: take a nested array and alter its inner array ; reality: the inner array seems to be getting copied Func ChangeIt(ByRef $aOuter) Local $aInner = $aOuter[0] $aInner[2] = 0 EndFunc ; Expected: [1, 2, 3, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✔ _ArrayDisplay($aInnerArray, 'Before') ; $aOuterArray passed by-ref, should receive reference to $aInnerArray ; Therefore should change $aInnerArray to [1, 2, 0, 4, 5] ChangeIt($aOuterArray) ; Expected: [1, 2, 0, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✘ _ArrayDisplay($aInnerArray, 'After') I suspect that either:
      the copy is taking place in the first line of the function (I couldn't find a way to access the inner array without first assigning it to a variable though); or ByRef doesn't propagate into inner levels of the data structure being passed, which seems less likely to me. Could someone please point me in the right direction to get this working as intended?
      Update: the answer
      ; WRONG: ; a one-element array containing a reference to the other array Local $aOuterArray[1] = [$aInnerArray] The assumption I made about this code is wrong—it actually copies $aInnerArray into $aOuterArray, so there are now two unrelated $aInnerArray instances.  It is not possible to store arrays in other arrays by reference.
      If it is necessary to refer to a mutable array in multiple places, consider holding it in a global variable.  Where a collection of mutable arrays needs to be accessed in multiple places (as in my case), consider storing them in a global array and referring to each sub-array by index (also known as the Registry pattern).
    • By VinMe
      HELLO All,
      is there any function in Auto it to Remove the repeating  strings separated by ","  which is present in the array.
      ex.
      Available state
      a[0]= D97,D96,,D85,D86,D85,D86,D85,D86,D85,,D86,D85,D86,D85,D86
      a[1]=D85,D24,,,,,D85
      Required state
      a[0]= D97,D96,D85,D86,
      a[1]=D85,D24
      thank  you in advance!
      vin!
×
×
  • Create New...