Parser problem PHP
I am going to write a parser that is going to get information from a website.
However something is wrong with this website and soon as i fetch the information and put it in a file, it's all gibberish.
The website is anidb.net
Could anyone tell me why i get gibberish instead of the HTML?
My code
<?php
$url = 'http://anidb.net/perl-bin/animedb.pl?show=anime&aid开发者_如何学运维=854';
file_put_contents("file.txt", file_get_contents($url));
?>
May i also add that using the browser's View Source function i see the HTML.
I checked the headers on the page that you specified and it's returning:
Content-Encoding: gzip
That means the 'gibberish' you're seeing is indeed gzip encoded. Here's another thread that should help you out: Decode gzipped web page retrieved via cURL in PHP
精彩评论