Hi All,
I met a problem using readLines function to return the data from Google
maps.
readLines(url("
http://ditu.google.cn/maps/geo?q=+qianshuichong,+guichi+anhui,+CN&output=csv&key=ABQIAAAAq8Fnd_oUka-7RdS6BrD7GBTqeABoQuNTXS36G_rkiwQnKRW6GBTkns8JpKz6y6dScgB8827dlddUlg"),
n=1, warn=FALSE)
[1] "200,4,30.6528380,117.4872250"
The above code is ok because the address is English, but it cannot work
when i change the address into zh-hans (Chinese simplified). See below.
readLines(url("http://ditu.google.cn/maps/geo?q=+ǰˮ³å<http://ditu.google.cn/maps/geo?q=+%E5%89%8D%E6%B0%B4%E5%86%B2>
,+¹ó³Ø+°²»Õ,+Öйú&output=csv&key=ABQIAAAAq8Fnd_oUka-7RdS6BrD7GBTqeABoQuNTXS36G_rkiwQnKRW6GBTkns8JpKz6y6dScgB8827dlddUlg&language=zh-CN®ion=zh_Hans"),
n=1, warn=FALSE)
[1] "400,0,0,0"
The returned value is wrong. I also tried several other options, but
still have the same problem. The interesting thing is if i paste the URL
into the IE explorer directly, it do return the correct values.
Anybody can give me some suggestions or hints to solve this?
Thanks a lot.
P.S. See below for the other possibilities i tried.
readLines(url("http://ditu.google.cn/maps/geo?q=+ǰˮ³å<http://ditu.google.cn/maps/geo?q=+%E5%89%8D%E6%B0%B4%E5%86%B2>
,+¹ó³Ø+°²»Õ,+Öйú&output=csv&key=ABQIAAAAq8Fnd_oUka-7RdS6BrD7GBTqeABoQuNTXS36G_rkiwQnKRW6GBTkns8JpKz6y6dScgB8827dlddUlg&language=zh-CN®ion=zh"),
n=1, warn=FALSE)
[1] "400,0,0,0"
readLines(url("http://ditu.google.cn/maps/geo?q=+ǰˮ³å<http://ditu.google.cn/maps/geo?q=+%E5%89%8D%E6%B0%B4%E5%86%B2>
,+¹ó³Ø+°²»Õ,+Öйú&output=csv&key=ABQIAAAAq8Fnd_oUka-7RdS6BrD7GBTqeABoQuNTXS36G_rkiwQnKRW6GBTkns8JpKz6y6dScgB8827dlddUlg&language=zh-CN"),
n=1, warn=FALSE)
[1] "400,0,0,0"
readLines(url("http://ditu.google.cn/maps/geo?q=+ǰˮ³å<http://ditu.google.cn/maps/geo?q=+%E5%89%8D%E6%B0%B4%E5%86%B2>
,+¹ó³Ø+°²»Õ,+Öйú&output=csv&key=ABQIAAAAq8Fnd_oUka-7RdS6BrD7GBTqeABoQuNTXS36G_rkiwQnKRW6GBTkns8JpKz6y6dScgB8827dlddUlg&language=zh-CN"),
n=1, warn=FALSE,encoding="UTF-8")
[1] "400,0,0,0"
--
-----------------
Jane Chang
Queen's
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.