用httplib2接收不完整的身体

时间:2010-10-23 14:05:29

标签: python httplib2

我在使用httplib2时遇到了一些麻烦。 当我使用谷歌浏览器浏览页面并保存源文件大约是106kB。当我使用httplib2请求文件时,我只得到99.x kB并且文件开头缺少大量文本。字节对象是否有某种大小限制?难道我做错了什么?

def __init__(self):
    self.url = 'http://somesite.org'
    self.html = ''
    self.BROWSER = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3'
    self.http = httplib2.Http()
    self.headers = {'Cookie': extract_from_chrome(),
                    'User-Agent': self.BROWSER}
    self.load()

def load(self):
    response, content = self.http.request(self.url, 'PUT', headers=self.headers)
    self.html = content.decode('utf-8')

0 个答案:

没有答案