禁用'保持活力'在TCP连接上

时间:2018-06-01 08:57:54

标签: r tcp httprequest rvest

是否可以

  

禁用'保持活力'请求之间的TCP连接

以编程方式在R?

让我们说我正在使用rvest包进行两次会议:

html_session("http://www.imenik.hr", encoding = "UTF-8", 
             user_agent('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'))

# How to disable 'keep alive' on the TCP connection?

html_session("http://www.imenik.hr", encoding = "UTF-8", 
             user_agent('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'))

如何删除'保持活力'在TCP连接上?

修改

我在httr选项中找到了tcp_keepalive选项。所以,我不确定答案是否正确:

html_session("http://www.imenik.hr", encoding = "UTF-8", 
                       user_agent('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'),
                       tcp_keepalive = FALSE)

0 个答案:

没有答案