135-1821-9792

PHP如何使用QueryList轻松实现一个百度网盘资源搜索引擎-创新互联

这篇文章主要介绍PHP如何使用QueryList轻松实现一个百度网盘资源搜索引擎,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

成都创新互联2013年至今,先为罗平等服务建站,罗平等地企业,进行企业商务咨询服务。为罗平企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

安装

使用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):获取百度搜索引擎

class Baidu:

● Baidu search($keyword):设置搜索关键词

● Baidu setHttpOpt(array $httpOpt = []):设置HTTP选项,查看: GuzzleHttp options

● int getCount():获取搜索结果总条数

● int getCountPage():获取搜索结果总页数

● Collection page($page = 1,$realURL = false):获取搜索结果

使用

实现一个百度网盘资源搜索引擎:

baidu()->search('site:pan.baidu.com 百度');
// 获取第一页数据,并获取真实URL连接地址
$data = $searcher->page(1,true);
print_r($data->all());

抓取结果:

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

Google搜索引擎插件

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

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

以上是PHP如何使用QueryList轻松实现一个百度网盘资源搜索引擎的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联成都网站设计公司行业资讯频道!

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享标题:PHP如何使用QueryList轻松实现一个百度网盘资源搜索引擎-创新互联
网址分享:http://kswsj.com/article/hieeh.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号