0
我想获得的价格,并从下面的网址蒸汽网站游戏名称的列表,但无法弄清楚如何xpathSApplyshould解析下面:R代表webscraping - 拉价格和名称
http://store.steampowered.com/search/?sort_by=Price & SORT_ORDER = ASC &放大器;';“>价格
这里是我的代码
require(RCurl)
require(XML)
url <- "http://store.steampowered.com/search/results?sort_by=Name&sort_order=ASC&category1=1"
SOURCE <- getURL(url,encoding="UTF-8") #Download the page
substring (SOURCE,1,200)
PARSED <- htmlParse(SOURCE) #Format the html code
##My problem is in this line below
(xpathSApply(PARSED, "//div[@class='col search_price']"))
很好的答案,尤其是创建标头的技巧。我使用此方法:PARSED < - htmlTreeParse(url,useInternal = TRUE)而不是RCurl plus getURL()加上htmlParse。有什么不同? – lawyeR 2014-08-28 01:59:43
谢谢@lawyeR。 Afaik,'htmlParse'只是'htmlTreeParse(useInternalNodes = TRUE,...)'的快捷方式。我离开了OP的'RCurl',因为它在需要的时候给了你更大的抓取控制。 – lukeA 2014-08-28 09:00:05