• 请不要在回答技术问题时复制粘贴 AI 生成的内容
5wcxcom
V2EX  ›  程序员

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

  •  
  •   5wcxcom · Aug 19, 2019 · 1493 views
    This topic created in 2467 days ago, the information mentioned may be changed or developed.

    如何搞呢?我发下代码 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);

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

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

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2988 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 00:22 · PVG 08:22 · LAX 17:22 · JFK 20:22
    ♥ Do have faith in what you're doing.