网页搜罗(在R?中)

use*_*432 2 r html-parsing web-scraping

我想要得到的公司的名字中的中间列页面(用蓝色粗体),以及是谁注册投诉的人的位置指示器(例如,"印度新德里",写在绿) .基本上,我想要一个包含两列的表(或数据框),一列用于公司,另一列用于位置.有任何想法吗?

Ram*_*ath 10

您可以使用XML包中的内容轻松完成此操作R.这是代码

url = "http://www.consumercomplaints.in/bysubcategory/mobile-service-providers/page/1.html"
doc = htmlTreeParse(url, useInternalNodes = T)

profiles = xpathSApply(doc, "//a[contains(@href, 'profile')]", xmlValue)
profiles = profiles[!(1:length(profiles) %% 2)]

states   = xpathSApply(doc, "//a[contains(@href, 'bystate')]", xmlValue)
Run Code Online (Sandbox Code Playgroud)