AppleScript名:freegeoipで指定IPアドレスの位置情報を取得 |
— Created 2017-12-20 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.5" use scripting additions use framework "Foundation" property |NSURL| : a reference to current application’s |NSURL| property NSData : a reference to current application’s NSData property NSJSONSerialization : a reference to current application’s NSJSONSerialization set aRes to getIPAddressInfoFreeGeoIP("91.108.183.75") of me as list of string or string –anything –> {time_zone:"Europe/Stockholm", city:"", zip_code:"", longitude:18.056, metro_code:0, country_name:"Sweden", latitude:59.3247, country_code:"SE", region_code:"", region_name:"", |ip|:"91.108.183.75"} –http://freegeoip.net on getIPAddressInfoFreeGeoIP(IPAddress) try with timeout of 10 seconds set link to "http://freegeoip.net/json/" & IPAddress set theURL to |NSURL|’s URLWithString:link set jsonData to NSData’s dataWithContentsOfURL:theURL set aJsonDict to (NSJSONSerialization’s JSONObjectWithData:jsonData options:0 |error|:(missing value)) return aJsonDict end timeout on error return missing value end try end getIPAddressInfoFreeGeoIP |
More from my site
(Visited 42 times, 1 visits today)