未找到Guzzle Client Crawler Url 404

时间:2018-09-26 04:59:54

标签: laravel web-crawler guzzle goutte domcrawler

我的网址是https://tiki.vn/sua-bot-meiji-noi-dia-hohoemi-milk-so-0-800g-p3678041.html

我使用软件包https://github.com/FriendsOfPHP/Goutte

$client = new Client();
    $guzzleClient = new GuzzleClient(array(
      'verify' => false
  ));
  $client->setClient($guzzleClient);

    $res = $client->request('GET', $url);
    // Get text
echo $res->filter('h1')->text();
当我运行代码结果404找不到。我有这个问题。请帮助我

1 个答案:

答案 0 :(得分:0)

我已经解决了问题

设置标题'User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'

$client->setHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36');