Laravel + Guzzle 实现简单爬虫

1. 爬取页面数据

$url = "http://www.zongscan.com/demo333/178.html";
$request = new GuzzleRequest('GET', $url);
$client = new \GuzzleHttp\Client();
$response = $client->send($request, ['timeout' => 5]);


2. 获取爬虫结果

$content = $response->getBody()->getContents();

 

3. 将结果转换为数组

$data = json_decode($content,true);

 

参考:https://www.zongscan.com/demo333/187.html

posted @ 2021-11-13 22:55  叶森白  阅读(254)  评论(0编辑  收藏  举报