Jump to content

Recommended Posts

Posted (edited)

  On 10/12/2010 at 2:43 PM, 'MrTiz said:

Hi, I' would get the location (geographical) off the pc where running the script; It's possible???

Sorry for my bad english, but I'm italian and I don't speak english very well

You can try to automate this by using your external ip in this website ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

Running this script should return the country of origin.

#include <FF.AU3>
#include <String.AU3>
#include <array.au3>


Global $Bin = InetRead ("http://www.ip-details.com/ip-search/")

Global $Page = BinaryToString ($Bin)

$country = _StringBetween($page, 'countryspan">' , '</span>')

msgbox (0, '' , $country[0])

  Reveal hidden contents

Posted

A little more granular

#include <String.AU3>
#include <array.au3>


Global $Bin = InetRead ("http://www.ip-details.com/ip-search/")
Global $Page = BinaryToString ($Bin)

$Address = _StringBetween ($Page, 'addressspan">' , '</span>')
$country = _StringBetween($page, 'countryspan">' , '</span>')
$longlat = _StringBetween ($page, 'latlongspan">' , '</span>')

$longlatstring = _ArrayToString($longlat)
$longlatstring2 = StringStripWS ($longlatstring, 1)

msgbox (0, '' , $country[0] & ", Nice Country!" & "  People are now en route to " & $Address[0] & "." & "  Weaponary is now aimed at " & $longlatstring2)

  Reveal hidden contents

Posted (edited)

Or in xml form with all details !

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

$Bin = InetRead ( 'http://xml.utrace.de/?query=' & _GetIP ( ) )
$Page = BinaryToString ( $Bin )
ConsoleWrite ( "$Page : " & $Page & @Crlf )
$_Country = _StringBetween ( $page, '<countrycode>', '</countrycode>' )
ConsoleWrite ( "!-->- Country : " & $_Country[0] & @Crlf )
$_Region = _StringBetween ( $page, '<region>', '</region>' )
ConsoleWrite ( "!-->- Region  : " & $_Region[0] & @Crlf )
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted (edited)

  On 10/12/2010 at 4:50 PM, 'iamtheky said:

A little more granular

#include <String.AU3>
#include <array.au3>


Global $Bin = InetRead ("http://www.ip-details.com/ip-search/")
Global $Page = BinaryToString ($Bin)

$Address = _StringBetween ($Page, 'addressspan">' , '</span>')
$country = _StringBetween($page, 'countryspan">' , '</span>')
$longlat = _StringBetween ($page, 'latlongspan">' , '</span>')

$longlatstring = _ArrayToString($longlat)
$longlatstring2 = StringStripWS ($longlatstring, 1)

msgbox (0, '' , $country[0] & ", Nice Country!" & "  People are now en route to " & $Address[0] & "." & "  Weaponary is now aimed at " & $longlatstring2)

Your script is funny :)

You can separate address with a comma? For example: Street, Number, District, ZIP Codes, City ;)

Edited by LordJugag
Posted (edited)

I found this topic: #500084 and had a go at eliminating _StringBetween() and instead opting for StringRegExp(). Based on the idea by wakillon.

Function:

; #FUNCTION# ====================================================================================================================
; Name ..........: _GetIP_Country
; Description ...: Retrieve details about the country of origin for an IP address.
; Syntax ........: _GetIP_Country()
; Parameters ....: Success - An array contain details:
;                  $aArray[0] - IP address
;                  $aArray[1] - ISP
;                  $aArray[2] - Region
;                  $aArray[3] - Country code
;                  Failuer - Returns 0 and sets @error to non-zero.
; Return values .: None
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func _GetIP_Country()
    Local $aSRE = StringRegExp(BinaryToString(InetRead('http://xml.utrace.de/?query=' & _GetIP())), _
            '<ip>([\d.]{7,15})</ip>\n' & _
            '<host>[^>]*</host>\n' & _
            '<isp>([^>]+)</isp>\n' & _
            '<org>[^>]+</org>\n' & _
            '<region>([^>]+)</region>\n' & _
            '<countrycode>([^>]+)</countrycode>\n', 3)
    If @error Then Return SetError(@error, 0, 0)
    Return $aSRE
EndFunc   ;==>_GetIP_Country
Example use of Function:

#include <Array.au3> ; Not Required, Only Needed For _ArrayDisplay()
#include <Inet.au3>

Local $aCountry = _GetIP_Country()
_ArrayDisplay($aCountry)
Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 2 months later...
Posted

Improved >> Now it's a standalone Function without the requirement for any #includes.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 1 month later...
Posted

You can find ip location making use of this site http://www.ip-details.com/ , it provides information at free cost & very good in service ..

Posted
Posted

MrTiz,

The solution by guinness in post #9 works best for me. I get the actual IP address even though I'm behind a router.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted
  Quote

The solution by guinness in post #9 works best for me. I get the actual IP address even though I'm behind a router.

Thanks!

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 1 year later...
Posted

Hi guinness, I know it is a very old post but your script is very compact and easy to implement an still working but only brings data when region <> "".

I was attempting to change StringRegExp with different options but still don't get to solve it.

For example for this IP (181.88.192.44) it doesn't work.

On the other hand, the site offers maximum amount of free requests per day and user, do you know any site to get free number of requests?

Thanks in advance!

 

 

 

 

Posted

Script works fine here. I get 4 fields all correct.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...