【发布时间】:2021-12-05 09:11:27
【问题描述】:
<a class="image teaser-image ng-star-inserted" target="_self" href="/politik/inland/neuwahlen-2022-welche-szenarien-jetzt-realistisch-sind/401773131">
我只是想提取“href”(例如上面的HTML标签)以便将它与本网站的域名“https://kurier.at”连接起来" 和网页抓取首页上的所有文章。
我尝试了以下代码
library(rvest)
library(lubridate)
kurier_wbpg <- read_html("https://kurier.at")
# I just want the "a" tags which come with the attribute "_self"
articleLinks <- kurier_wbpg %>% html_elements("a")%>%
html_elements(css = "tag[attribute=_self]") %>%
html_attr("href")%>%
paste("https://kurier.at",.,sep = "")
当我执行到上面代码块的 html_attr("href") 部分时,我得到的结果是
character(0)
我认为选择 HTML 元素标签有问题。 我需要这方面的帮助吗?
【问题讨论】:
标签: r web-scraping href rvest html-target