Guzzle Client Crawler Url Not found 404

254 Views Asked by At

I'm url https://tiki.vn/sua-bot-meiji-noi-dia-hohoemi-milk-so-0-800g-p3678041.html

I use package 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();
When i run code result 404 Not Found. I'm having this problem. Please help me

1

There are 1 best solutions below

0
On

I has solved the problem

Set header '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');