GeoIP()

Veröffentliche deine funktionierenden Skripte und Funktionen

Moderator: jNizM

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

GeoIP()

07 Feb 2021, 08:36

Inspiriert durch :arrow: diese Anfrage im Englischen Forum stellte sich mir die Frage ob, ähnlich der Geo-Location-Bestimmung für mobile devices eine Option für imobile PC's verfügbar ist. Dem ist so. IP Geo Location. Muss zwar ohne GPS und cell tower Ortung auskommen, doch für die annähernde Bestimmung der Zeitzone (sowie weiterer IP basierter Ausgaben) genügt es (unter Vorbehalt).

Drohende Verbesserungsvorschläge (fast) jeder Art (z.B. zur json/xml-Verbuxelung) werden gerne (zur Kenntnis) genommen. Have phun! :mrgreen:

Code: Select all


GeoIP()																	; load object using the 'https://ipapi.co/' API

MsgBox % GeoIP.region													; your current IP's assigned region ..
MsgBox % GeoIP.org														; .. organisation
MsgBox % GeoIP.version													; .. version
MsgBox % GeoIP.ip														; .. value. Check https://ipapi.co/api/#introduction for details!

For k, v in GeoIP 														; extract all assignments from the previously loaded GeoIP object 
	lst .= k ": " v "`n"
MsgBox % clipboard := lst												; display all assignments of your current IP

GeoIP("?")																; display GeoIP' help
Return

GeoIP(type:="") {
	if (type = "?") || (type = "help")
		help()
	else {
		Global GeoIP	:= {}
		whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
		whr.SetTimeouts(0, 5000, 5000, 100000)								; adjust timeouts accordingly. Default: (0, 30000, 30000, 600000)
		whr.Open("GET","https://ipapi.co/csv/", False)						; optional output formats are: json, jsonp, xml, csv, yaml.
		whr.Send()
		Sleep 100
		k := StrSplit(StrSplit(Trim(whr.ResponseText,"`n`r"),"`n").1,",")	; processing retrieved csv's 1st line
		v := StrSplit(StrSplit(Trim(whr.ResponseText,"`n`r"),"`n").2,",")	; processing retrieved csv's 2nd line
		Loop % k.Length() 
			GeoIP[Trim(k[A_Index],"`n`r")] := v[A_Index]
		Return
		}
	}

help(){
MsgBox, 
(%
Example:

   Once 'GeoIP()' has been loaded you can get the 
   'timezone' of a PC's geographical location
   using 'GeoIP.timezone' or 'GeoIP["timezone"]'

   Ie 'MsgBox % GeoIP.timezone' possible output: 'Europe/Berlin'.
   The following keys/options might be interesting as well.

	asn
	city
	continent_code
	country
	country_area
	country_calling_code
	country_capital
	country_code
	country_code_iso3
	country_name
	country_population
	country_tld
	currency
	currency_name
	in_eu
	ip
	languages
	latitude
	longitude
	org
	postal
	region
	region_code
	timezone
	utc_offset
	version
	)
ExitApp
}

Dasselbe nochmal als Funktion: Auf zur
Peep -

Tags: :arrow: external IPgeofencinglocationGeoIPtimezoneCountry Code

Wie identifiziert man/frau lat/long innerhalb eines Radius (zB um (d)einen Wohnort) zum GeoFencing? Werde hieraus nicht wirklich schlau: http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates :think:
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: GeoIP()

02 Apr 2021, 16:09

BoBo wrote:
07 Feb 2021, 08:36
Wie identifiziert man/frau lat/long innerhalb eines Radius (zB um (d)einen Wohnort) zum GeoFencing? Werde hieraus nicht wirklich schlau: http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates :think:

Verschiedene API-Services bieten eine Abfragemöglichkeite mit dem Parameter 'radius' oder 'bounds' an.
Mit Tools wie :arrow: diesem lässt sich ein "Koordinaten-Fenster" ermitteln, was z.B. zur Restriktierung dienen kann!
HTH :)

Return to “Skripte und Funktionen”

Who is online

Users browsing this forum: No registered users and 17 guests