Sou*_*dra 5 url user-agent r httpwebrequest http-headers
如何更改R中的http请求中的用户代理字符串?我如何弄清楚我当前的用户代理字符串是什么样的?
提前致谢.
Mar*_*rek 10
options("HTTPUserAgent")或getOption("HTTPUserAgent")打印您当前的设置,并且options(HTTPUserAgent="My settings")是更改它的方法.
接受的答案中使用的解决方案options()将在整个会话中全局更改设置(除非您将其更改回来)。
要在 发出的请求中临时更改用户代理download.file(),您需要使用headers参数:
download.file("https://httpbin.org/user-agent",
destfile = "test.txt",
headers = c("User-Agent" = "My Custom User Agent"))
Run Code Online (Sandbox Code Playgroud)
available.packages()从 R 4.0.0 开始,您还可以在和中使用此参数,install.packages()它将被转发到download.file().
| 归档时间: |
|
| 查看次数: |
2552 次 |
| 最近记录: |