@$k=$_get['k'] ? $_get['k'] : '不念博客'; @$u=$_get['u'] ? $_get['u'] : 'www.bunian.cn'; $rn='50'; $url = "https://www.baidu.com/s?ie=utf-8&wd=".$k."&rn=".$rn; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_header, false); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_useragent, 'mozilla/5.0 (windows nt 6.1) applewebkit/537.11 (khtml, like gecko) chrome/23.0.1271.1 safari/537.11'); $res = curl_exec($ch); $rescode = curl_getinfo($ch, curlinfo_http_code); curl_close($ch); preg_match_all('/(.*?)/si', $res, $p); for ($ii = 0; $ii < count($p[1]); $ii++){ $pos=strpos($p[1][$ii],$u); if(is_integer($pos)){ $rn= $ii+1; break; } } echo $rn;
2. [代码][php]代码 跳至 [1] [2] [3] [全屏预览] 欢迎大家来我的博客做客
3. [代码][php]代码 跳至 [1] [2] [3] [全屏预览]
