Sign in to follow this  
Followers 0
ChrisO

IP Lookup function utilizing INetRead

2 posts in this topic

Hey everyone,

I have the need to be able to lookup information on an IP and present it to the user. At the moment I'm using InetRead along with the following website "http://www.ipgp.net/api/xml/127.0.0.1".

Once I have that page stored I can use regular expressions to pull the information I need. The code looks like this:

Func _IPLookup($IP)
    local $Code, $Country, $City, $Region, $ISP = ""
    local $rawHTML = InetRead("http://www.ipgp.net/api/xml/" & $IP,16)
    if @error <> 0 then 
        consolewrite(@error)
        
        Return "Error"
    EndIf

    consolewrite($rawHTML)
    
    $rawHTML = BinaryToString($rawHTML)
    
    local $RegExpResults = StringRegExp($rawHTML,'<Code>(.+)</Code>',3)
        if IsArray($RegExpResults) then
            $Code = $RegExpResults[0]
        Else
            $Code = ""
        EndIf
    local $RegExpResults = StringRegExp($rawHTML,'<Country>(.+)</Country>',3)
        if IsArray($RegExpResults) then
            $Country = $RegExpResults[0]
        Else
            $Country = ""
        EndIf
    local $RegExpResults= StringRegExp($rawHTML,'<City>(.+)</City>',3)
        if IsArray($RegExpResults) then
            $City = $RegExpResults[0]
        Else
            $City = ""
        EndIf
    local $RegExpResults= StringRegExp($rawHTML,'<Region>(.+)</Region>',3)
        if IsArray($RegExpResults) then
            $Region = $RegExpResults[0]
        Else
            $Region = ""
        EndIf
    local $RegExpResults = StringRegExp($rawHTML,'<ISP>(.+)</ISP>',3)
        if IsArray($RegExpResults) then
            $ISP = $RegExpResults[0]
        Else
            $ISP = ""
        EndIf
    
    ;Create the message string
    local $strmsg = "IP: " & $IP & @CRLF & "Country: " & $Country & @CRLF & "City: " & $City & @CRLF & "Region: " & $Region & @CRLF & "ISP: " & $ISP
    TrayTip("IP Lookup",$strmsg,30,1)
EndFunc

This worked fine previously but now I've been getting "Error: 13" output to the console. Then on the 3rd attempt of running the function, the script locks and I have to Ctrl-Alt-Del out of it.

Am I doing something wrong here or is it a problem with a proxy or similar? Any help much appreciated.

Chris,

Share this post


Link to post
Share on other sites



A good IP lookup tool that enables you to geolocate and and trace an Ip address location is http://www.ipfingerprints.com/geolocation.php .

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  
Followers 0