1

I am trying to scrape a webpage using simple_html_dom and cUrl also. Butin results it returning encrypted type page, (Unreadable characters).

Using Simple Html Dom

$url = 'http://mangafox.me/manga/world_trigger/v01/c001/2.html';
$html = file_get_html($url);
echo $html->plaintext;

Result is This Encrypted Unreadable HTML

With Curl

   $ch = curl_init("http://mangafox.me/manga/world_trigger/v01/c001/2.html");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    $content = curl_exec($ch);
    curl_close($ch);

    echo $content;

Result is same as above :( This Behaviour is really strange, Please help.

Noman Ali
  • 3,160
  • 10
  • 43
  • 77

1 Answers1

0

Actually, the encrypted content was a GZIPed content.

Resolved it by decoding it with builtin PHP function

if ( ! function_exists('gzdecode'))
{

    function gzdecode($data) 
    {
        // strip header and footer and inflate

         return gzinflate(substr($data, 10, -8));
     }
 }

Reference :Here is original post

Community
  • 1
  • 1
Noman Ali
  • 3,160
  • 10
  • 43
  • 77