R:从 Google 图片搜索页面检索 image_urls

问题描述 投票:0回答:0

我正在使用 R 进行编码并构建一个网页抓取脚本,以便以编程方式在 Google 上搜索产品图像并将其下载到文件夹中。我有一个 for 循环,其中有一个步骤来获取图像 URL

#Define the desired Google image search page
page <- read_html("https://www.google.com/search?q=Djeco%20DD04490%20image&tbm=isch&tbs=isz:lt,islt:0.5")
#Fetch the image urls programatically
image_urls <- page %>% html_nodes(".rg_i") %>% html_attr("data-src")
#Continue the rest flow and download the image jpg files from the image url list
...

但是,

image_urls
始终为空,无法继续进行。 我该如何解决这个问题并从示例页面获取图像网址?

r rvest xml2
© www.soinside.com 2019 - 2024. All rights reserved.