I would like to know how to set the encoding parameter so that when I download text, it ‘looks’ the same as when I saw it on the page source in a web browser, e.g.:
readLines("http://www.baidu.com/s?wd=r+project")[132]
[1] "<div id=\"foot\">©2010 Baidu <span>´ËÄÚÈÝϵ°Ù¶È¸ù¾ÝÄúµÄÖ¸Áî×Ô¶¯ËÑË÷µÄ½á¹û£¬²»´ú±í°Ù¶ÈÔ޳ɱ»ËÑË÷ÍøÕ¾µÄÄÚÈÝ»òÁ¢³¡</span></div>"
When it should be displayed as:
> <div id="foot">©2010 Baidu <span>此内容系百度根据您的指令自动搜索的结果,不代表百度赞成被搜索网站的内容或立场</span></div>
Any help would be much appreciated!
# windows 7
sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] XML_3.2-0.1 RCurl_1.4-4.1 bitops_1.0-4.1 rcom_2.2-3.1 rscproxy_1.3-1
loaded via a namespace (and not attached):
[1] tools_2.12.0
1 Answer