- library(rvest)
- key = 3560
- words <- read_html("http://bbs.nju.edu.cn/bbstdoc?board=V_Suggestions&start=3560",encoding = 'gbk')
- pop <- html_table(html_nodes(words,"table"),fill = TRUE)[[1]]
- res <- pop
- #for(i in 1:9){
- for(i in 1: 12){
- key <- key - 19
- url = paste('http://bbs.nju.edu.cn/bbstdoc?board=V_Suggestions&start=',key-19,sep="")
- readurl <- read_html(url,edcoding = 'gbk' )
-
- popsug <- html_table(html_nodes(readurl,"table"),fill = TRUE)[[1]]
-
- res <- rbind(res,popsug)
- }
for ( i in 1:9 )则不会报错
如果 for ( i in 1: x) x >= 10
则报错如下
Error in html_table(html_nodes(readurl, "table"), fill = TRUE)[[1]] : subscript out of bounds


雷达卡




京公网安备 11010802022788号







