【发布时间】:2021-06-12 15:23:19
【问题描述】:
我正在寻找一种在谷歌搜索中使用 R 进行网络抓取的方法。鉴于困难(cookie 和不稳定的标签),我想分享一些想法,关于如何在谷歌搜索上使用 R 进行网络抓取仍然是可能的。
这里是一个例子。我选择谷歌“法拉利”并尝试检索所有谷歌搜索页面的 h3。我特别想得到每个 h3 aref-links。
但是,我只能检索 h3 标签和其他一些内容。
url = 'https://www.google.com/search?q=ferrari'
first_page <- read_html(url)
h3 <- first_page %>%
html_nodes("a h3")
h3_links <- first_page %>%
html_nodes("a h3") %>% html_attr("href")
basic <- first_page %>%
html_nodes("span span")
paragraphs <- first_page %>%
html_nodes("div div")
因此,我只想问是否有人知道如何在 google 上搜索尽可能多的网页。这可能有助于找到合适的方式在 google 上进行网络抓取并讨论 google 跟踪方式。
【问题讨论】:
-
这显然会破坏 google ToS,他们会立即阻止您。
-
他们已经掌握了很多关于一切的信息。既然 Google 获取了我们和每个人的数据,为什么我们不在 Google 中跟踪我们的数据呢?为了进行公开讨论,我证明了@user12256545 的贡献:
-
library(robotstxt) robotstxt::paths_allowed("google.com/search?q=ferrari") # 否 因此,我只想问是否有另一个 waz 可以像使用 RSelenium 或通过 Docker 一样绕过这个障碍
标签: r web-scraping google-search