【发布时间】:2020-09-09 07:28:37
【问题描述】:
我正在尝试从该网站提取所有购物中心名称(例如 CityPlaza、Fashion Walk): https://www.discoverhongkong.com/eng/explore/shopping/major-shopping-malls-throughout-city.html
查看 html 代码,看起来购物中心的文本都存储在标签“h5”下。因此,我使用以下代码尝试提取,但它没有给我想要的文本。
url <- "https://www.discoverhongkong.com/eng/explore/shopping/major-shopping-malls-throughout-city.html"
txt = getURL(url)
PARSED <- htmlParse(txt)
mall_text <- xpathSApply(PARSED, "//h5", xmlValue)
这肯定与我在 xpathSApply 函数中作为参数放置的路径有关,因为我对 html 知之甚少。有人可以帮忙吗?
【问题讨论】:
标签: html r xml web-scraping