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...插件