• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP使用QueryList轻松实现一个百度网盘资源搜索引擎

php 搞代码 3年前 (2022-01-21) 51次浏览 已收录 0个评论

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

class Baidu:

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

● Baidu setHttpOpt(array $httpOpt = []):设置HTT1本文来#源gaodai$ma#com搞$代*码*网

搞代gaodaima码

P选项,查看: GuzzleHttp options

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

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

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

使用

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

<?phprequire '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());

抓取结果:

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&#8230;

更多PHP相关知识,请访问搞代码

以上就是PHP使用QueryList轻松实现一个百度网盘资源搜索引擎的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP使用QueryList轻松实现一个百度网盘资源搜索引擎

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址