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);