1 Star 0 Fork 0

iamcer / PageDataList

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
BaiduSearch.php 1.08 KB
Copy Edit Web IDE Raw Blame History
不是靖哥哥 authored 2018-12-04 10:19 . ok
<?php
//引入自动加载文件
require_once 'service/PageDataList.php';
require 'vendor/autoload.php';
use QL\QueryList;
use QL\Ext\AbsoluteUrl;
use QL\Ext\DisguisePlugin;
use service\PageDataList;
/**
* 百度搜索类
*
* */
class BaduSearch{
/**
* 执行搜索
* @param string $keyword 搜索关键词
* @return array
*/
function run($keyword=''){
$obj = new PageDataList('https://www.baidu.com/', [
'pn' => '1',
'link' => 'https://www.baidu.com/s?wd='.$keyword
], [
'pn' => ['#page>a:not(".n") .pc', 'text', '', function ($content) {
return $content;
}],
'link' => ['#page>a:not(".n")', 'href', '', function ($content) {
return $content;
}],
]);
return $obj->getData([
'title' => ['.c-container .t', 'text'],
'link' => ['.c-container .t>a', 'href'],
], 2000000 );
}
}
$obj = new BaduSearch();
print_r($obj->run('海居网'));

Comment ( 0 )

Sign in for post a comment

PHP
1
https://gitee.com/hjsiamcer/PageDataList.git
git@gitee.com:hjsiamcer/PageDataList.git
hjsiamcer
PageDataList
PageDataList
master

Search