【发布时间】:2025-11-29 22:05:01
【问题描述】:
当我尝试使用 HTTP 协议下载 URL 时,我收到 400 错误:
library(httr)
x1 <- "http://www.sonnenwende-harsewinkel.de/öko-gas/bürgerwerke/"
resp <- httr::GET(x1, httr::timeout(60))
resp[["status_code"]]
#400
切换到HTTPS协议后问题解决:
x2 <- "https://www.sonnenwende-harsewinkel.de/öko-gas/bürgerwerke/"
resp <- httr::GET(x2, httr::timeout(60))
resp[["status_code"]]
#200
当我在网络浏览器中输入 HTTP 地址时,我会被重定向到 HTTPS 地址。是否也可以使用httr 进行重定向?
【问题讨论】:
-
R Bloggers 可能会有所帮助。
标签: r web-scraping httr