简体   繁体   中英

Get Request Using PyCurl after logging into website

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM