python2 urllib2,Python urllib2保持活着
How can I make a "keep alive" HTTP request using Python's urllib2?
解決方案
Use the urlgrabber library. This includes an HTTP handler for urllib2 that supports HTTP 1.1 and keepalive:
>>> import urllib2
>>> from urlgrabber.keepalive import HTTPHandler
>>> keepalive_handler = HTTPHandler()
>>> opener = urllib2.build_opener(keepalive_handler)
>>> urllib2.install_opener(opener)
>>>
>>> fo = urllib2.urlopen('http://www.python.org')
Note: you should use urlgrabber version 3.9.0 or earlier, as the keepalive module has been removed in version 3.9.1
There is a port of the keepalive module to Python 3.
總結
以上是生活随笔為你收集整理的python2 urllib2,Python urllib2保持活着的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gis怎么通过水库划分子流域_到底是谁在
- 下一篇: 心电图心电轴怎么计算_浅谈心电图