Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.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
用R删除javascript_Javascript_R_Web Scraping - Fatal编程技术网

用R删除javascript

用R删除javascript,javascript,r,web-scraping,Javascript,R,Web Scraping,我想从metal-archives.com下载表格,确切地说是从,但有一个大问题。这些表是由javascript生成的。事实上,我不知道在这种情况下该怎么办 是否有可能使用R和XML包解析此站点?以下是JSON格式的所有信息 多亏了用户,我实现了我想要的。下面是解决我的问题的代码 a<-1:8 b<-200*a x<-paste("http://www.metal-archives.com/artist/ajax-rip?iDisplayStart=",b,"&sEch

我想从metal-archives.com下载表格,确切地说是从,但有一个大问题。这些表是由javascript生成的。事实上,我不知道在这种情况下该怎么办


是否有可能使用R和XML包解析此站点?

以下是JSON格式的所有信息

多亏了用户,我实现了我想要的。下面是解决我的问题的代码

a<-1:8
b<-200*a
x<-paste("http://www.metal-archives.com/artist/ajax-rip?iDisplayStart=",b,"&sEcho=",a,sep="")
x<-c(x,"http://www.metal-archives.com/artist/ajax-rip?iDisplayStart=1700&sEcho=9")

JSONparse<-function(x){
  library(XML)
  doc<-htmlParse(x)
  str<-xpathApply(doc,'//p',xmlValue)[[1]][1]
  x1<-strsplit(str,'\\[')
  x1<-x1[[1]][-1]
  x1<-x1[-1]

  x2<-strsplit(x1,'\\",')
  x3<-lapply(x2, function(y) {
    y<-gsub('\\t','',y)
    y<-gsub('\\n','',y)
    y<-gsub('\\r','',y)
    y<-gsub('\\\"','',y)
    y<-gsub('\\]}','',y)
    y<-gsub('\\],','',y)
    y<-as.data.frame(t(y))
    y})

  allinall<-do.call('rbind',x3)
  colnames(allinall)<-c("Artist","Country","Band","When","Why")
  allinall
}

metallum<-lapply(x,JSONparse)
metallum<-do.call('rbind',metallum)

aAs我知道,1700条记录中只有200条……有没有办法获取所有记录?对于下一页,请按如下方式进行:其中iDisplayStart=sEcho*200bumbu。有没有可能显示创建JSON版本的过程