3
我正在努力與pycurl。 這些都是我的頭:圖片下載PycURL讓我破碎圖片
headers.append('User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0')
headers.append('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
headers.append('Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3')
headers.append('Accept-Encoding: gzip, deflate')
headers.append('Accept-Charset: UTF-8,*')
headers.append('Connection: Keep-Alive')
原文:
我能得到什麼:
正如你所看到的,一個我pycurl得到的是壞了。如果我將它們與文本比較工具進行比較,它告訴我它們是相同的。 (原來只有LF和破損的CRLF在行尾有區別,但我改變了這一點,現在我有相同的圖像,仍然損壞)
我從哪裏下載的主機不是原因。我試圖從保管箱和本地apache做同樣的事情。兩者都不起作用。
這是我如何保存圖像:
self.buffer = StringIO.StringIO()
# other curl options like ssl, cookies, followlocation and GET Request URL Setup to the Image: http://dl.dropbox.com/u/25733986/test.jpg
self.curl.setopt(pycurl.WRITEFUNCTION, self.buffer.write)
# -> curl.perform()
f = open("temp/resources/%s" % (filename,), 'w')
f.write(self.buffer.getvalue())
f.close()
我會很高興,如果任何人有這方面的一些建議,這樣我就可以找到我的錯誤。
我也嘗試設置'self.curl.setopt(pycurl.CRLF,1)'爲1和0,這並沒有幫助。 – Hurix 2011-06-09 12:01:34