gpt4 book ai didi

php - 'file_get_contents' 内容已加密?

转载 作者:行者123 更新时间:2023-12-02 21:52:05 24 4
gpt4 key购买 nike

问题是当我使用file_get_contents从该网站获取源代码(HTML)时,我收到的结果不是纯html代码。

我使用的代码:

$source = file_get_contents("http://mp3.zing.vn/bai-hat/Dance-With-My-Father-Luther-Vandross/ZWZ9D6FD.html");
echo $source;
// OR print_r($source);

我收到的来源:

��}{�#Ǒ��-��!E��=��Mv�5�B���R�����h��E�HV7YE�������a�X��p{��[�:�!{��;,v��u��Or��̬��Y��M��ʌ̌�����������F��ޖ����ػ��S� #�~��H�7k�����ʎȦ2���M?�ު&D�����t���$u�O��N���>%(Y����I��Vb�[���VN�=�[�![*�dE*�]3:�ޑ�xiA���Z��g ��祇VejI �R�y�֨�ea��o��s�M/�... *MORE

我尝试使用 cURL,但我也收到了相同的结果:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://mp3.zing.vn/bai-hat/Dance-With-My-Father-Luther-Vandross/ZWZ9D6FD.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$source = curl_exec($ch);
curl_close($ch);

我认为我收到的源代码一定是加密的,但是如果我使用浏览器查看源代码,源代码不会被加密。

最终,我真的不知道发生了什么,以及如何获取纯源 (纯 HTML)?

最佳答案

它是 gzip 压缩的,只需设置正确的编码即可开始

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://mp3.zing.vn/bai-hat/Dance-With-My-Father-Luther-Vandross/ZWZ9D6FD.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_ENCODING , "gzip");
$source = curl_exec($ch);
curl_close($ch);

关于php - 'file_get_contents' 内容已加密?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18398510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com