PHP file_get_contents 输出烦人的字符?
PHP file_get_contents outputs annoying characters?
我正在尝试从网站 file_get_contents,但它会输出奇怪的字符,例如 ��}��r��H������y����M����n��'2I��"��^ÏjI -[D������T��8��w��|��-Y
<?
echo file_get_contents("http://mp3yum.top");
?>
有没有办法从这个网站上抓取一些内容。
在调用外部源之前需要使用 CURL。
$data = get_url('http://mp3yum.top');
echo($data);
function get_url($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
输出画面:
我正在尝试从网站 file_get_contents,但它会输出奇怪的字符,例如 ��}��r��H������y����M����n��'2I��"��^ÏjI -[D������T��8��w��|��-Y
<?
echo file_get_contents("http://mp3yum.top");
?>
有没有办法从这个网站上抓取一些内容。
在调用外部源之前需要使用 CURL。
$data = get_url('http://mp3yum.top');
echo($data);
function get_url($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
输出画面: