wangqs / querylist-rule-baidu-news
QueryList Plugin: Baidu News searcher. QueryList百度资讯频道搜索插件
v1.0.2
2021-08-24 15:14 UTC
Requires
- php: >=7.0
Requires (Dev)
- jaeger/querylist: dev-master
This package is auto-updated.
Last update: 2024-10-24 22:36:09 UTC
README
QueryList Plugin: Baidu News searcher.
QueryList插件:百度搜索引擎
QueryList:https://github.com/jae-jae/QueryList
Installation for QueryList4
composer require wangqs/querylist-rule-baidu-news
API
- BaiduNews baidu($pageNumber = 10):get BaiduNews Searcher.
class BaiduNews:
- BaiduNews search($keyword):set search keyword.
- BaiduNews setHttpOpt(array $httpOpt = []):Set the http option,see: GuzzleHttp options
- int getCount():Get the total number of search results.
- int getCountPage():Get the total number of pages.
- Collection page($page = 1,$realURL = false):Get search results
Usage
- Installation Plugin
use QL\QueryList; use QL\Ext\BaiduNews; $ql = QueryList::getInstance(); $ql->use(BaiduNews::class); //or Custom function name $ql->use(BaiduNews::class,'baidu');
- Example-1
$baiduNews = $ql->baiduNews(10) $searcher = $baiduNews->search('QueryList'); $count = $searcher->getCount(); $data = $searcher->page(1); $data = $searcher->page(2); $searcher = $baiduNews->search('php'); $countPage = $searcher->getCountPage(); for ($page = 1; $page <= $countPage; $page++) { $data = $searcher->page($page); }
- Example-2
$searcher = $ql->baiduNews()->search('QueryList'); $data = $searcher->setHttpOpt([ // Set the http proxy 'proxy' => 'http://222.141.11.17:8118', // Set the timeout time in seconds 'timeout' => 30, ])->page(1);
- Example-3
$baiduNews = $ql->baiduNews(3) $searcher = $baiduNews->search('QueryList'); $data = $searcher->page(1); print_r($data->all()); // Get real url $data = $searcher->page(1,true); print_r($data->all());