QueryList使用jQuery的方式來作採集,擁有豐富的插件。php
下面來演示QueryList
使用Baidu搜索引擎
插件輕鬆實現站內搜索。html
使用Composer安裝:git
composer require jaeger/querylist
GitHub: https://github.com/jae-jae/Qu...github
composer require jaeger/querylist-rule-baidu
GitHub: https://github.com/jae-jae/Qu...composer
class Baidu:網站
<?php require 'vendor/autoload.php'; use QL\QueryList; use QL\Ext\Baidu; $ql = QueryList::use(Baidu::class); // 搜索百度網盤網站,包含‘百度’關鍵詞的資源 $searcher = $ql->baidu()->search('site:pan.baidu.com 百度'); // 獲取第一頁數據,並獲取真實URL鏈接地址 $data = $searcher->page(1,true); print_r($data->all());
抓取結果:ui
Array ( [0] => Array ( [title] => 百度網盤_享你所想 [link] => http://pan.baidu.com/ ) [1] => Array ( [title] => 百度網盤 客戶端下載 [link] => https://pan.baidu.com/download ) [2] => Array ( [title] => 百度網盤-開放平臺 [link] => https://pan.baidu.com/platform/read ) // .... )
$baidu = $ql->baidu(15); // 設置每頁搜索15條結果 $searcher = $baidu->search('QueryList'); $count = $searcher->getCount(); // 獲取搜索結果總條數 $data = $searcher->page(1); $data = $searcher->page(2); $searcher = $baidu->search('php'); $countPage = $searcher->getCountPage(); // 獲取搜索結果總頁數 for ($page = 1; $page <= $countPage; $page++) { $data = $searcher->page($page); } $data = $searcher->setHttpOpt([ // 設置http代理 'proxy' => 'http://222.141.11.17:8118', // Set the timeout time in seconds 'timeout' => 30, ])->page(1);
固然除了Baidu搜索引擎插件,QueryList也有Google搜索引擎插件,也能夠實現一樣的功能。搜索引擎
文檔: https://doc.querylist.cc/site...
GitHub: https://github.com/jae-jae/Qu...插件