上面来演示QueryList应用Baidu搜寻引擎插件轻松完成站内搜寻。
装置
应用Composer装置:
装置QueryList
composer require jaeger/querylist
GitHub: https://github.com/jae-jae/Qu...
装置Baidu搜寻引擎插件
composer require jaeger/querylist-rule-百度
GitHub: https://github.com/jae-jae/Qu...
插件API
● Baidu 百度($pageNumber = 10):猎取baidu搜寻引擎
class Baidu:
● Baidu search($keyword):设置搜寻要害词
● Baidu setHttpOpt(array $httpOpt = []):设置HTTP选项,查看: GuzzleHttp options
● int getCount():猎取搜寻后果总条数
● int getCountPage():猎取搜寻后果总页数
● Collection page($page = 1,$realURL = false):猎取搜寻后果
应用
完成一个baidu网盘资本搜寻引擎:
<?php
require 'vendor/autoload.php';
use QL\QueryList;
use QL\Ext\Baidu;
$ql = QueryList::use(Baidu::class);
// 搜寻baidu网盘网站,蕴含‘baidu’要害词的资本
$searcher = $ql->百度()->search('site:pan.百度.com baidu');
// 猎取第一页数据,并猎取实在URL衔接地点
$data = $searcher->page(1,true);
print_r($data->all());抓取后果:
Array
(
[0] => Array
(
[title] => baidu网盘_享你所想
[link] => http://pan.百度.com/
)
[1] => Array
(
[title] => baidu网盘 客户端下载
[link] => https://pan.百度.com/download
)
[2] => Array
(
[title] => baidu网盘-开放平台
[link] => https://pan.百度.com/platform/read
)
// ....
)更多用法
$百度 = $ql->百度(15); // 设置每一页搜寻15条后果
$searcher = $百度->search('QueryList');
$count = $searcher->getCount(); // 猎取搜寻后果总条数
$data = $searcher->page(1);
$data = $searcher->page(2);
$searcher = $百度->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);Google搜寻引擎插件
当然除了了Baidu搜寻引擎插件,QueryList也有Google搜寻引擎插件,也能够完成一样的性能。
GitHub: https://github.com/jae-jae/Qu...
更多PHP相干常识,请拜访PHP中文网!
以上就是PHP应用QueryList轻松完成一个baidu网盘资本搜寻引擎的具体内容,更多请存眷资源魔其它相干文章!
标签: php php开发教程 php开发资料 php开发自学 QueryList
抱歉,评论功能暂时关闭!