0

我根据我的 IP 地址获得位置我现在的问题是我住在“维尔茨堡”(德国),但我的脚本说“维尔茨堡”。我怎样才能得到“¸”到“ü”?

--Get the IP
set webadress to do shell script "curl http://bot.whatismyipaddress.com/"
set tURL to "http://whatismyipaddress.com/ip/" & webadress

--Get the location
set TID to AppleScript's text item delimiters
set webadress to do shell script "curl " & tURL
set AppleScript's text item delimiters to ¬
    "<tr><th>City:</th><td>"
set text1 to text item 2 of webadress
set AppleScript's text item delimiters to "</td></tr>"
set location to text item 1 of text1
4

1 回答 1

0

该网站使用 ISO-8859-1,但您可以使用iconv -f iso-8859-1 -t utf8.

do shell script "curl http://whatismyipaddress.com/ip/$(curl http://bot.whatismyipaddress.com/) | iconv -f iso-8859-1 -t utf8 | sed -En 's|<tr><th>City:</th><td>(.*)</td></tr>|\\1|p'"

于 2012-12-16T00:04:39.263 回答