I am trying to get the source code of a php web page with a proxy, but it is showing not printable characters. The output I got is as follows:
"Date: Tue, 09 Feb 2016 10:29:14 GMT
Server: Apache/2.4.9 (Unix) OpenSSL/1.0.1g PHP/5.5.11 mod_perl/2.0.8-dev Perl/v5.16.3
X-Powered-By: PHP/5.5.11
Set-Cookie: PHPSESSID=jmqasueos33vqoe6dbm3iscvg0; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Encoding: gzip
Vary: Accept-Encoding
Content-Length: 577
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html
�TMo�@�G����7�)P�H�H�DS��=U�=�U�]˻��_�Ycl�T�*�>��eg��
����Z�
�V�N�f�:6�ԫ�IkZ77�A��nG�W��ɗ���RGY��Oc`-ο�ƜO��~?�V��$�
�l4�+���n�].W��TLJSx�/|�n��#���>��r����;�l����H��4��f�\ �SY�y��7��"
how to decode this code using python, i tried to use
decd=zlib.decompress(data, 16+zlib.MAX_WBITS)
but is not giving the decoded data
The proxy which i am using is working fine for few other web applications. It showing non printable characters for some web applications, how to decode this?
As I am using proxy I dont want to use get() and urlopen() or any other requests from python program.
requestsmodule the content will be automatically decompressed for you.datathat you passed tozlib.decompress()?data? Ifdatacontains only gzipped data,zlib.decompress(data, 16+zlib.MAX_WBITS)should successfully decompress the data. Or you could use thegzipmodule as shown in my answer. But what are you passing indata?