1
我需要一個可以重新使用連接的python http客戶端,它支持在使用流時使用它。它將用於解析xml流和sax樣式。保持活動狀態的Python流http客戶端
我想出了一個解決方案,但我不知道這是最好的一個(在Python編寫的HTTP客戶端的相當多的方式)
class Downloader():
def __init__(self, host):
self.conn = httplib.HTTPConnection(host)
def get(self, url):
self.conn.request("GET", url)
resp = self.conn.getresponse()
while True:
data = resp.read(10)
if not data:
break
yield data
謝謝鄉親!