Get Request Using PyCurl after logging into website

一笑奈何 提交于 2019-12-24 08:50:06

问题


After doing a post to log into my website, I try to do a get on my the site and I get a bunch of garbage "�0������`&)��붋...." instead of the data from my site. Why is that? How do I fix that?


回答1:


Obviously a dead thread, but if anyone else stumbles across this, funky data like that is most likely compressed with zlib or gzip. If you are using pycurl, this should do the trick:

import pycurl

ch = pycurl.Curl()
ch.setopt(pycurl.URL, 'http://example.com')
ch.setopt(pycurl.ENCODING, '')
ch.perform()

Setting the ENCODING option to an empty string sets the 'Accept-Encoding' headers to all encodings supported by libcurl and tells libcurl to decode the response data. OP was probably setting the headers manually and libcurl wasn't expecting encoded data.



来源:https://stackoverflow.com/questions/3225012/get-request-using-pycurl-after-logging-into-website

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!