public function getData($name, $page = 1)
{
$name = urlencode($name);//需要对关键词进行url解析,否者部分带字符的标题会返回空
//$name = urlencode($name);
$url = 'https://m.baidu.com/s?ie=UTF-8&wd=' . $name;
$res = $this->curl_request($url);
// 一,获取正文
$reach_word = substr($res, strpos($res, '<div id="results" class="results">'), strpos($res, '<div id="page-relative" class="se-page-relative">') - strpos($res, '<div id="results" class="results">'));//截取需要的内容
// 获取标题
$regex1 = "/<span.*?class=\".*?c-title-text.*?\".*?>(.*?)<\/span>/is";
preg_match_all($regex1, $reach_word, $title_matches, PREG_PATTERN_ORDER);
$title = @$title_matches[1];
// 获取描述
$regex2 = "/<span data-a-46b6314e><span data-a-46b6314e>(.*?)<\/span><\/span>/is";
preg_match_all($regex2, $reach_word, $des_matches, PREG_PATTERN_ORDER);
$des = @$des_matches[1];
$output['title'] = $title;
$output['des'] = $des;
return $output;
}