当前位置: 首页 > 后端技术 > PHP

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

时间:2023-03-29 23:08:25 PHP

QueryList使用jQuery做采集,有丰富的插件。下面演示一下QueryList使用百度搜索引擎插件轻松实现站内搜索。使用Composer安装:installQueryListcomposerrequirejaeger/querylistGitHub:https://github.com/jae-jae/Qu...安装百度搜索引擎插件composerrequirejaeger/querylist-rule-baiduGitHub:https://github.com/jae-jae/Qu...插件APIBaidubaidu($pageNumber=10):获取百度搜索引擎类Baidu:Baidusearch($keyword):设置搜索关键字BaidusetHttpOpt(array$httpOpt=[]):设置HTTPOptions,view:GuzzleHttpoptionsintgetCount():获取搜索结果总数intgetCountPage():获取搜索结果总页数Collectionpage($page=1,$realURL=false):获取搜索结果使用百度网盘资源搜索引擎:baidu()->search('site:pan.baidu.comBaidu');//获取首页数据,并获取真实的URL连接地址$数据=$搜索r->page(1,true);print_r($data->all());抓取结果:Array([0]=>Array([title]=>百度网盘_分享你的想法[链接]=>http://pan.baidu.com/)[1]=>数组([标题]=>百度网盘客户端下载[链接]=>https://pan.baidu.com/download)[2]=>数组([标题]=>百度网盘-开放平台[链接]=>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();//获取搜索结果的总页数($page=1;$page<=$countPage;$page++){$data=$searcher->page($page);}$data=$searcher->setHttpOpt([//设置http代理'proxy'=>'http://222.141.11.17:8118',//以秒为单位设置超时时间'timeout'=>30,])->page(1);谷歌搜索引擎插件当然,QueryList除了百度搜索引擎插件外,还有一个谷歌搜索引擎插件,也可以实现同样的功能文档:https://doc.querylist.cc/网站...GitHub:https://github.com/jae-jae/Qu...