1

I am using a simple_html_dom parser. The following code is returning garbage output:

$opts = array(
                'http'=>array(
            'method'=>"GET",
            'header'=>
                    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n".
                    "Accept-Encoding: gzip, deflate\r\n".
                    "Accept-language: en-US,en;q=0.5\r\n" .
            "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6\r\n".
            "Cookie: foo=bar\r\n"
                )
    ); 
        $context = stream_context_create($opts);
        $html = file_get_html("http://freepsdfiles.net/",false,$context);

        echo $html;

enter image description here

Please help. I also tried file_get_contents() but didn't work.

Alexander van Oostenrijk
  • 4,644
  • 3
  • 23
  • 37
Future King
  • 3,819
  • 6
  • 28
  • 37

1 Answers1

2

Removing 'gzip' from Accept-Encoding will return the un-gzipped response.

See also https://stackoverflow.com/a/10105319/1491542 for ungzip function if you want to handle it yourself.

Community
  • 1
  • 1
vidario
  • 479
  • 2
  • 5