R以编程方式更改IP地址

R Change IP Address programmatically

目前正在通过将不同的字符串传递给 html_session() 方法来更改 user_agent。

是否还有一种方法可以在抓取网站时通过计时器更改您的 IP 地址?

您可以通过 use_proxy 使用代理(更改您的 ip),如下所示:

html_session("you-url", use_proxy("proxy-ip", port))

有关详细信息,请参阅:?httr::use_proxy

要检查它是否正常工作,您可以执行以下操作:

require(httr)

content(GET("https://ifconfig.co/json"), "parsed")
content(GET("https://ifconfig.co/json", use_proxy("138.201.63.123", 31288)), "parsed")

第一个电话将 return 您的 IP。第二次调用应该 return 138.201.63.123 as ip.

此代理来自 http://proxylist.hidemyass.com/ - 没有任何保证...