Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript RCurl处理汉字_Javascript_R_Character Encoding_Rcurl - Fatal编程技术网

Javascript RCurl处理汉字

Javascript RCurl处理汉字,javascript,r,character-encoding,rcurl,Javascript,R,Character Encoding,Rcurl,这是我的密码。为什么不能正确解码汉字: library(XML) require(RCurl) myURL <- "http://data.eastmoney.com/zjlx/600066.html" html <- getURL(myURL,.encoding = "gb2312") print(Encoding(html)) basicInfo <- htmlParse(html) #print(Encoding(b

这是我的密码。为什么不能正确解码汉字:

    library(XML)
    require(RCurl)
    myURL <- "http://data.eastmoney.com/zjlx/600066.html"
    html <- getURL(myURL,.encoding = "gb2312")
    print(Encoding(html))
    basicInfo <- htmlParse(html)
    #print(Encoding(basicInfo))
    tables <- readHTMLTable(basicInfo)
库(XML)
需要(RCurl)

myURL问题在于网站使用javascript动态地向表中添加数据。如果在禁用js的浏览器中加载页面,您会注意到那里也看不到任何数据。

我在javascript方面取得了一些有限的成功,但在编码方面没有成功(在将字符编码交给R时,字符编码有问题,我不知道如何更正):

在Windows上安装软件包和所需文件 需要(devtools) 安装_github('seleniumJars','LluisRamon') 安装_github('relinium','LluisRamon')) #加载包 要求(释放) #启动Firefox的新实例(必须已安装在您的计算机上) 火狐
# On Windows install the packages and required files
require(devtools)
install_github('seleniumJars', 'LluisRamon')
install_github('relenium', 'LluisRamon')

# Load package
require(relenium)

# Start a new instance of Firefox (this must already be installed on your computer)
firefox <- firefoxClass$new()

# We go to the url using the function get.
firefox$get("http://data.eastmoney.com/zjlx/600066.html")

# The html from the webpage can be obtained with the getPageSource (and returning a "character") function.
html <- firefox$getPageSource()

# Parse the html using the XML package
doc <- htmlParse(html)

# Extract your table
tables <- readHTMLTable(doc, stringsAsFactors=FALSE)
mytable <- tables$dt_1

           V1    V2     V3          V4      V5           V6      V7          V8      V9         V10     V11          V12     V13
1  2014-07-24 18.30  2.81%  3893万  10.63%   -323万  -0.88%  4217万  11.52% -1600万  -4.37%  -2293万  -6.26%
2  2014-07-23 17.80 -0.50%  1287万   8.63%  27.48万   0.18%  1259万   8.44%  -333万  -2.24%   -953万  -6.39%
3  2014-07-22 17.89  4.25%  7765万  18.46%   5729万  13.62%  2036万   4.84% -4574万 -10.87%  -3190万  -7.58%