我正试图使用rvest从二手车广告中抓取一些数据。然而,我无法抓取数据,这使<dl>,<dt>或<dd>html标记使用htmlnodes((函数。
更具体地说,我想在数据框中抓取以下汽车广告的下图中的功能。https://www.autoscout24.be/nl/aanbod/mercedes-benz-slk-200-benzine-grijs-e77f7a3e-76b1-4676-88a0-b52c9574068a?cldtidx=3&cldtsrc=listPage
在此处输入图像描述
有人能帮我吗?
谢谢!Arne
我已经尝试过这个(以及其他几种组合——试错(。我想要一个数据帧,其中<dt>标记是关键,并且<dd>tag是值
install.packages("rvest")
library(rvest)
autoscout_mercedes <- read_html("https://www.autoscout24.be/nl/lst/mercedes-benz?sort=standard&desc=0&ustate=N%2CU&cy=B&atype=C")
features <- autoscout_mercedes %>%
html_nodes("div.sc-ellipsis") %>%
html_nodes("a") %>%
html_attr("href")
features
我还包括了一个html脚本的打印屏幕。在这里输入图像描述
这将是我的方法,带有以下示例链接:
link <- read_html("https://www.autoscout24.de/angebote/opel-corsa-1-2-16v-klima-
nsw-zv-benzin-blau-f189ee9d-b634-4bb7-8051-0e4a1f62846f?
&cldtidx=1&cldtsrc=listPage&searchId=1225151069")
name <- html_text(html_nodes(link, "dl > dt"))
name
value <- html_text(html_nodes(link, "dd"))
value
test <- data.frame(name,value)
head(test)
h2 dd
1 Zustand nGebrauchtn
2 Fahrzeughalter n3n
3 Marke nOpeln
4 Modell nCorsan
5 Erstzulassung n2000n
6 Außenfarbe nBlaun