【发布时间】:2020-08-27 10:09:12
【问题描述】:
我想从网站上抓取官方法律(这里是example)。可以在 html 网站的菜单中访问这些文档。我设法从 github 等网站提取链接并下载 PDF,但是,我很难从此类网站提取链接。我尝试了以下代码:
library(rvest)
# read html
page <- read_html("https://bl.clex.ch/app/de/texts_of_law/780")
# from nodes I would like to get the links where the PDFs are stored
raw_list <- page %>% # takes the page above for which we've read the html
html_nodes("a") %>% # find all links in the page
html_attr("href")
由于结果为空字符串,在该网站上找不到链接
character(0)
我的问题:
- 与通过 github 项目主页上的链接访问的存储在 github 上的 PDF 相比,链接网站上的菜单有什么不同?
- 如何访问链接并下载此菜单中存储的所有 PDF?
【问题讨论】:
标签: r web-scraping rvest