提问以下 phantomjs 不好爬取头条的是什么情况屏蔽了吗

2019-08-19 16:55:32 +08:00
 5wcxcom

如何搞呢?我发下代码 require 'vendor/autoload.php'; use JonnyW\PhantomJs\Client;

$client = Client::getInstance();

$client->getEngine()->setPath('/www/wwwroot/phantomjs-2.1.1-linux-x86_64/bin/phantomjs'); //设置 phantomjs 位置 $client->getEngine()->addOption('--load-images=false'); $client->getEngine()->addOption('--ignore-ssl-errors=true'); $client->getEngine()->addOption('--local-to-remote-url-access=true'); $client->isLazy();// 让客户端等待所有资源加载完毕

$url = $_REQUEST['url']; $url = 'https://m.toutiaoimg.cn/group/6695506106313080836/?app=news_article&timestamp=1558936734&share_ht_uid=58738473383&did=55927714761&utm_medium=toutiao_android&tt_from=copy_link'; $request = $client->getMessageFactory()->createRequest($url, 'GET');

$timeout = 10000; //设置超时 $request->setTimeout($timeout);

$request->addSetting('userAgent', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3704.400 QQBrowser/10.4.3587.400');//设置 ua

$response = $client->getMessageFactory()->createResponse(); $client->send($request, $response);

$allHtml = $response->getContent(); print_r($allHtml);

打开显示: 您访问的页面不存在

它是做了什么处理吗?应该如何绕过呢?

1056 次点击
所在节点    程序员
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/593227

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX