- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在创建一个脚本来抓取网站 www.piratebay.se。脚本在两三天前工作正常,但现在我遇到了问题。
这是我的代码:
$URL = 'http://thepiratebay.se';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt($ch, CURLOPT_COOKIE, "language=pt_BR; c[thepiratebay.se][/][language]=pt_BR");
$fonte = curl_exec ($ch);
curl_close ($ch);
echo $fonte;
此代码的响应不是干净的 HTML,而是如下所示:
��[s8N>��k��9��-ىmI7��$��8��.v��͕����$h����y��G��Sg:ӷ>��5������ʱ��aor&
����.v)����������) d��w��8w��l����c��u""1����F*G��ِ��2$��6��C��}��z(bw�� 4Ƒz6��S��t4��K��x��6u����~��T����ACJb ��T^3��USPI:Mf��n��'��4���� ��XE��QQ&��c5��`'β��T Y]D��Q��nBfS��}a��%�� ����R) ��Zn��̙ ��8IB��a����L��
我已经尝试在 .htaccess、PHP 和 cURL 上使用用户代理,但没有成功。
最佳答案
添加这个:
curl_setopt($ch, CURLOPT_ENCODING , "gzip");
在我的本地环境中测试过,工作正常。
关于php - cURL 正在从 Pirate Bay 检索编码的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23520466/
你能告诉我如何用两组 R.drawable.images 盗版创建 if - else 语句吗? 我已经尝试过,但我收到一个错误代码,提示 pirates is un-resolved。 Bitmap
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 可以用事实和引用来回答它. 6年前关闭。 Improve this
引自 ZeroMQ 指南 However, with a little extra work, this humble pattern becomes a good basis for real wo
我目前正在用 php 做一个网站,我们使用 Session 变量来存储每个用户的权限级别。 例如,如果你们中的任何一个人访问该网站,您将自动获得一个值为“member”的 session 变量。 我想
我正在创建一个脚本来抓取网站 www.piratebay.se。脚本在两三天前工作正常,但现在我遇到了问题。 这是我的代码: $URL = 'http://thepiratebay.se'; $ch
我是一名优秀的程序员,十分优秀!