【发布时间】:2015-09-21 01:24:49
【问题描述】:
我正在尝试抓取http://then.gasbuddy.com/。
我正在 R 中运行下一个代码
library(RCurl)
library(XML)
doc <- htmlTreeParse('http://www.southcarolinagasprices.com/GasPriceSearch.aspx?typ=adv&fuel=A&srch=0&area=All%20Areas&station=All%20Stations&tme_limit=4')
rootNode <- xmlRoot(doc)
((rootNode[[2]][4])[1][[1]])[[15]][[1]][[11]][[1]][[1]][[2]][[8]][[1]][[2]][[1]][[1]][[1]][[1]][[1]][[1]]
#<div class="p1"/>
x <- matrix(, nrow = 20, ncol = 4)
x[1,1] <- xmlValue(((rootNode[[2]][4])[1][[1]])[[15]][[1]][[11]][[1]][[1]][[2]][[8]][[1]][[2]][[1]][[1]][[1]][[1]][[1]][[1]])
但是我有这个错误
替换的长度为零
如何减去 p1 并将其放入矩阵中?
【问题讨论】:
标签: r web-scraping rcurl webscarab