时间:2021-07-01 10:21:17 帮助过:34人阅读
$v){ $v = iconv("GBK","utf-8",urldecode($v)); if(strlen($v)>9){ $v = str_replace('"','',$v); $v = str_replace("'",'',$v); } $topkey[] = $v; } } if(count($topkey)>10){ file_put_contents($file,""); } } return $topkey;}function huoduan_get_baidu($q,$p=1,$time=86400){ $s = urlencode($q); $file = ROOT_PATH.'/cache/so_'.md5($q.$p).'.php'; $list = ''; if(is_file($file) && time()-filemtime($file)<$time){ include($file); }else{ $html = huoduan_get_html('http://www.baidu.com/s?wd='.$s.'&pn='.(($p-1)*10).'&rn=15&tn=baidulocal&ie=utf-8'); //$html = iconv("GBK","utf-8",$html); if(!strpos($html,'未找到和您的查询"','',1); $lists['title'] = huoduan_get_content_array($body,'','
',1); $lists['des'] = huoduan_get_content_array($body,'','
',1); $lists['blink'] = huoduan_get_content_array($body,'','',1); foreach($lists['title'] as $k=>$v){ $list['data'][$k]['title'] = huoduan_get_body($lists['title'][$k],'','',1); $list['data'][$k]['title'] = str_replace('','',$list['data'][$k]['title']); $list['data'][$k]['title'] = str_replace('','',$list['data'][$k]['title']); $list['data'][$k]['link'] = huoduan_get_body($lists['title'][$k],''); $list['data'][$k]['blink'] = $lists['blink'][$k]; } $pager = huoduan_get_body($html,'','
',1); $pagerli = huoduan_get_content_array($pager,'',0); if(strpos($pager,'下一页')){ $pcount = count($pagerli); $list['pnum'] = strip_tags($pagerli[$pcount-i(a(a),-12,1)]); $list['pnum'] = trim($list['pnum'],'['); $list['pnum'] = trim($list['pnum'],']'); $list['pnext']=1; }else if(is_array($pagerli)){ $pcount = count($pagerli); $list['pnum'] = strip_tags($pagerli[$pcount-i(a,112,1)]); $list['pnum'] = trim($list['pnum'],'['); $list['pnum'] = trim($list['pnum'],']'); $list['pnext']=0; } if(is_array($list['data'])){ file_put_contents($file,""); } } } return $list;}function huoduan_get_baidu_xg($q){ $s = urlencode($q); $file = ROOT_PATH.'/cache/xg_'.md5($q).'.php'; if(is_file($file)){ include($file); }else{ $html = huoduan_get_html('http://www.baidu.com/s?wd='.$s.'&ie=utf-8'); //$html = iconv("GBK","utf-8",$html); if(strpos($html,'相关搜索')){ $body = huoduan_get_body($html,'相关搜索','',1); $xglist = huoduan_get_content_array($body,'<'.substr(a,64,1),'',0); foreach($xglist as $k=>$v){ $xgdata[$k] = strip_tags($v); } file_put_contents($file,""); } } return $xgdata;} function huoduan_get_body($str,$start,$end,$option){ $strarr=explode($start,$str); $tem=$strarr[1]; if(empty($end)){ return $tem; }else{ $strarr=explode($end,$tem); if($option==1){ return $strarr[0]; } if($option==2){ return $start.$strarr[0]; } if($option==3){ return $strarr[0].$end; } else{ return $start.$strarr[0].$end; } } } function huoduan_replace_content($str,$start,$end,$replace = '',$option){ $del_code = huoduan_get_body($str,$start,$end,$option); $str = str_replace( $del_code, $replace, $str ); return $str; } function huoduan_zz($string){ $string = str_replace( '/', '\/', $string ); $string = str_replace( '$', '\$', $string ); $string = str_replace( '*', '\*', $string ); $string = str_replace( '"', '\"', $string ); $string = str_replace( "'", "\'", $string ); $string = str_replace( '+', '\+', $string ); $string = str_replace( '^', '\^', $string ); $string = str_replace( '[', '\[', $string ); $string = str_replace( ']', '\]', $string ); $string = str_replace( '|', '\|', $string ); $string = str_replace( '{', '\{', $string ); $string = str_replace( '}', '\}', $string ); $string = str_replace( '%', '\%', $string ); $string = str_replace( '-', '\-', $string ); $string = str_replace( '(', '\(', $string ); $string = str_replace( ')', '\)', $string ); $string = str_replace( '>', '\>', $string ); $string = str_replace( '<', '\<', $string ); $string = str_replace( '?', '\?', $string ); $string = str_replace( '.', '\.', $string ); $string = str_replace( '!', '\!', $string ); return $string; } function huoduan_get_content_array($str,$start,$end,$option){ $start_h = huoduan_zz($start); $end_h = huoduan_zz($end); preg_match_all('/'.$start_h.'(.+?)'.$end_h.'/is',$str,$match); $count = count($match[1]); for($i=0;$i<$count;$i++){ if($option==1){ $arr[$i]=$match[1][$i]; } else if($option==2){ $arr[$i]=$start.$match[1][$i]; } else if($option==3){ $arr[$i]=$match[1][$i].$end; }else{ $arr[$i]=$start.$match[1][$i].$end; } } return $arr; }非常感谢版主!是怎么解的说说流程可以?
$v){ $v = iconv("GBK","utf-8",urldecode($v)); if(strlen($v)>9){ $v = str_replace('"','',$v); $v = str_replace("'",'',$v); } $topkey[] = $v; } } if(count($topkey)>10){ file_put_contents($file,""); } } return $topkey;}function huoduan_get_baidu($q,$p=1,$time=86400){ $s = urlencode($q); $file = ROOT_PATH.'/cache/so_'.md5($q.$p).'.php'; $list = ''; if(is_file($file) && time()-filemtime($file)<$time){ include($file); }else{ $html = huoduan_get_html('http://www.baidu.com/s?wd='.$s.'&pn='.(($p-1)*10).'&rn=15&tn=baidulocal&ie=utf-8'); //$html = iconv("GBK","utf-8",$html); if(!strpos($html,'未找到和您的查询"','',1); $lists['title'] = huoduan_get_content_array($body,'','
',1); $lists['des'] = huoduan_get_content_array($body,'','
',1); $lists['blink'] = huoduan_get_content_array($body,'','',1); foreach($lists['title'] as $k=>$v){ $list['data'][$k]['title'] = huoduan_get_body($lists['title'][$k],'','',1); $list['data'][$k]['title'] = str_replace('','',$list['data'][$k]['title']); $list['data'][$k]['title'] = str_replace('','',$list['data'][$k]['title']); $list['data'][$k]['link'] = huoduan_get_body($lists['title'][$k],''); $list['data'][$k]['blink'] = $lists['blink'][$k]; } $pager = huoduan_get_body($html,'','
',1); $pagerli = huoduan_get_content_array($pager,'',0); if(strpos($pager,'下一页')){ $pcount = count($pagerli); $list['pnum'] = strip_tags($pagerli[$pcount-i(a(a),-12,1)]); $list['pnum'] = trim($list['pnum'],'['); $list['pnum'] = trim($list['pnum'],']'); $list['pnext']=1; }else if(is_array($pagerli)){ $pcount = count($pagerli); $list['pnum'] = strip_tags($pagerli[$pcount-i(a,112,1)]); $list['pnum'] = trim($list['pnum'],'['); $list['pnum'] = trim($list['pnum'],']'); $list['pnext']=0; } if(is_array($list['data'])){ file_put_contents($file,""); } } } return $list;}function huoduan_get_baidu_xg($q){ $s = urlencode($q); $file = ROOT_PATH.'/cache/xg_'.md5($q).'.php'; if(is_file($file)){ include($file); }else{ $html = huoduan_get_html('http://www.baidu.com/s?wd='.$s.'&ie=utf-8'); //$html = iconv("GBK","utf-8",$html); if(strpos($html,'相关搜索')){ $body = huoduan_get_body($html,'相关搜索','',1); $xglist = huoduan_get_content_array($body,'<'.substr(a,64,1),'',0); foreach($xglist as $k=>$v){ $xgdata[$k] = strip_tags($v); } file_put_contents($file,""); } } return $xgdata;} function huoduan_get_body($str,$start,$end,$option){ $strarr=explode($start,$str); $tem=$strarr[1]; if(empty($end)){ return $tem; }else{ $strarr=explode($end,$tem); if($option==1){ return $strarr[0]; } if($option==2){ return $start.$strarr[0]; } if($option==3){ return $strarr[0].$end; } else{ return $start.$strarr[0].$end; } } } function huoduan_replace_content($str,$start,$end,$replace = '',$option){ $del_code = huoduan_get_body($str,$start,$end,$option); $str = str_replace( $del_code, $replace, $str ); return $str; } function huoduan_zz($string){ $string = str_replace( '/', '\/', $string ); $string = str_replace( '$', '\$', $string ); $string = str_replace( '*', '\*', $string ); $string = str_replace( '"', '\"', $string ); $string = str_replace( "'", "\'", $string ); $string = str_replace( '+', '\+', $string ); $string = str_replace( '^', '\^', $string ); $string = str_replace( '[', '\[', $string ); $string = str_replace( ']', '\]', $string ); $string = str_replace( '|', '\|', $string ); $string = str_replace( '{', '\{', $string ); $string = str_replace( '}', '\}', $string ); $string = str_replace( '%', '\%', $string ); $string = str_replace( '-', '\-', $string ); $string = str_replace( '(', '\(', $string ); $string = str_replace( ')', '\)', $string ); $string = str_replace( '>', '\>', $string ); $string = str_replace( '<', '\<', $string ); $string = str_replace( '?', '\?', $string ); $string = str_replace( '.', '\.', $string ); $string = str_replace( '!', '\!', $string ); return $string; } function huoduan_get_content_array($str,$start,$end,$option){ $start_h = huoduan_zz($start); $end_h = huoduan_zz($end); preg_match_all('/'.$start_h.'(.+?)'.$end_h.'/is',$str,$match); $count = count($match[1]); for($i=0;$i<$count;$i++){ if($option==1){ $arr[$i]=$match[1][$i]; } else if($option==2){ $arr[$i]=$start.$match[1][$i]; } else if($option==3){ $arr[$i]=$match[1][$i].$end; }else{ $arr[$i]=$start.$match[1][$i].$end; } } return $arr; }
可以帮我解完整代码?这就是完整的,只不过按习惯略去了最后的 ?>
这就是完整的,只不过按习惯略去了最后的 ?>
版主你是用什么方法解出来的要!人气教程排行
- 174次 1 php如何获取跳转前的url
- 174次 2 php格林威治时间转换成当前时间的方法
- 174次 3 为什么php不能做大型系统?
- 174次 4 range函数怎么用
- 174次 5 php中计算页面加载时间几种方法总结_PHP教程
- 174次 6 求帮助,关于paypal支付返回值修改订单状态
- 174次 7 typecho怎么配置文章内容页?
- 174次 8 PhpStorm左侧structure不显示文件的方法列表是这么回事?
- 174次 9 查看PHP的环境变量_PHP
- 174次 10 PHP Primary script unknown 解决方法总结
- 174次 11 php的命名空间与自动加载实现方法
- 174次 12 解决laravel 出现ajax请求419(unknown status)的问题
- 173次 13 php 如何删除mysql记录
- 173次 14 PHP如何替换数组中的指定元素
- 173次 15 怎么去除字符串中非汉字、非字母、非数字的字符
- 173次 16 mysql如何一次执行多条SQL语句
- 173次 17 修改header里面的Connection为close解决方法
- 173次 18 PHP基于session.upload_progress 实现文件上传进度显示功能详解
- 173次 19 php5.6.x到php7.0.x特性小结
- 172次 20 php为什么会出现504错误