我根据我的IP地址获取位置 我现在的问题是我住在“Würzburg”(德国),但我的剧本上写着“W?rzburger”。 我怎样才能将“¸”变为“ü”?
--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
答案 0 :(得分: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'"