【发布时间】:2023-03-15 15:30:01
【问题描述】:
我正在尝试从亚马逊获取产品评论者的位置。比如这个网页
我需要得到HAINESVILLE, ILLINOIS, United States
我使用 rvest 包进行网页抓取。
这是我所做的:
library(rvest)
url='https://www.amazon.com/gp/profile/amzn1.account.AH55KF4JK5IKKJ77MPOLHOR4YAQQ/ref=cm_cr_dp_d_gw_tr?ie=UTF8'
page = read_html(url)
我收到如下错误:
Error in open.connection(x, "rb") : HTTP error 403.
但是,以下工作:
con <- url(url, "rb")
page = read_html(con)
但是,在我阅读的页面中,我无法提取任何文本。例如,我想提取审稿人的位置。
page %>%
html_nodes("#customer-profile-name-header .a-size-base a-color-base")%>%
html_text()
我什么都没有
character(0)
谁能帮我弄清楚我做错了什么?提前非常感谢。
【问题讨论】:
-
您是如何选择“#customer-profile-name-header .a-size-base a-color-base”的 您是否使用了选择器小工具?这可能会有所帮助:queryxchange.com/q/27_51801321/…
标签: r web-scraping rvest