【发布时间】:2021-06-15 13:55:52
【问题描述】:
我想抓取genecards.com。 robotstxt 包中的函数paths_allowed() 表示允许抓取有关给定基因的信息。我的例子是:https://www.genecards.org/cgi-bin/carddisp.pl?gene=TOP1
我想提取摘要部分,即从:“TOP1 基因的Entrez 基因摘要”到“TOP1 基因的基因维基条目”。一次是整个部分,或者是一个接一个的摘要。
我用类标签“.list-unstyled”一个接一个地尝试了它
到目前为止我的过程:
genes <- c("TOP1")
paths_allowed(paths = "https://www.genecards.org/cgi-bin/carddisp.pl?gene=TOP1")
base <- xml2::read_html(paste0(base_genecards, genes[1]))
base %>% html_nodes(".list-unstyled") # refer to the in the hierarchy lowest class
这给出了结果
{xml_nodeset (0)}
我知道我必须在之后使用html_text(),但我没有做到这一点,因为我没有在此页面上获得任何查询。我在 imdb 上试了一下,效果很好。
我很难将摘要文本输入 R。我的错误在哪里?
谢谢
【问题讨论】:
-
仅供参考,它是 scrape、scraping、scraped 和 scraper 不是报废、报废,报废或报废。 “废弃”意味着像垃圾一样扔掉:-(
标签: html r web-scraping