R中带有RCurl和XML的Web抓取-使用xpathapply

时间:2018-08-21 07:03:13

标签: xml web-scraping rcurl

我正在尝试从以下网页中抓取所有结果URL:

http://www.attheraces.com/results/25-Jul-2018

基本上,我正在寻找一个包含以下链接的数据框:

http://www.attheraces.com/racecard/Bath/25-July-2018/1400
http://www.attheraces.com/racecard/Bath/25-July-2018/1430
http://www.attheraces.com/racecard/Sandown/25-July-2018/1750

等 (我认为英国和IRE有42多个)。

我已经开始使用RCurl和XML库,如下所示:

library(RCurl)
library(XML)
url = "http://www.attheraces.com/results/25-Jul-2018"
txt = getURL(url)
txt = htmlTreeParse(txt, asText = TRUE, useInternalNodes = TRUE)

在HTML中,我可以看到我想要的所有网址都在描述符中:

li class =“ meeting-race”

但是,现在我不确定如何使用xpathApply函数一次将所有URL提取到数据帧中?

非常感谢。

0 个答案:

没有答案