百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>网页制作> PHP运用QueryList轻松实现一个baidu网盘资源搜寻引擎
分享文章到:

PHP运用QueryList轻松实现一个baidu网盘资源搜寻引擎

发布时间:09/01 来源:未知 浏览: 关键词:
QueryList使用jQuery的方式来做采集,具有丰硕的插件。

下面来演示QueryList使用Baidu搜索引擎插件轻松实现站内搜索。

安置

使用Composer安置:

安置QueryList

composer require jaeger/querylist

GitHub: https://github.com/jae-jae/Qu...

安置Baidu搜索引擎插件

composer require jaeger/querylist-rule-baidu

GitHub: https://github.com/jae-jae/Qu...

插件API

● Baidu 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->baidu()->search('site:pan.baidu.com baidu');
// 猎取第一页数据,并猎取真实URL连接地址
$data = $searcher->page(1,true);
print_r($data->all());

抓取结果:

Array
(
    [0] => Array
        (
            [title] => baidu网盘_享你所想
            [link] => http://pan.baidu.com/
        )
    [1] => Array
        (
            [title] => baidu网盘 客户端下载
            [link] => https://pan.baidu.com/download
        )
    [2] => Array
        (
            [title] => baidu网盘-开放平台
            [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);

Google搜索引擎插件

当然除了Baidu搜索引擎插件,QueryList也有Google搜索引擎插件,也可以实现一样的功效。

GitHub: https://github.com/jae-jae/Qu...

更多PHP相关知识,请拜访PHP中文网!

以上就是PHP使用QueryList轻松实现一个baidu网盘资源搜索引擎的具体内容,更多请关注百分百源码网其它相关文章!

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有150人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板