加入收藏 | 设为首页 | 会员中心 | 我要投稿 开发网_新乡站长网 (https://www.0373zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP百度收录量查询接口源码,百度收录量API查询PHP源码

发布时间:2022-12-07 11:05:35 所属栏目:PHP教程 来源:
导读:  百度收录量API查询PHP源码

  /*

  Plugin Name:百度收录量

  Version:1.0

  Description:根据域名返回百度收录量

  Author:绿游

  Author URL:

  */

  $domain
  百度收录量API查询PHP源码
 
  /*
 
  Plugin Name:百度收录量
 
  Version:1.0
 
  Description:根据域名返回百度收录量
 
  Author:绿游
 
  Author URL:
 
  */
 
  $domain = (isset($_GET['domain']))?$_GET['domain']:$_POST['domain'];
 
  if(empty($domain)) echo '查询域名不能为空';
 
  $count = baiduSL ($domain);
 
  if(!isset($count)) showjson(array('code'=>200502,'msg'=>'查询失败,请重试!'));
 
  if(!$count) $count = 0;
 
  $result=array(
 
  'code'=>1,
 
  'domain'=>$domain,
 
  'data'=>$count
 
  );
 
  print_r(json_encode($result));
 
  unset($value,$url_arr,$domain,$row,$hostrow,$site,$resulturl,$result,$ch);
 
  function baiduSL ($domain) {
 
  $baidu='%3A'.$domain;
 
  $bdsite=BD_curl($baidu);
 
  $bdsite = str_replace(array("\r\n", "\r", "\n", ' '), '', $bdsite);
 
  preg_match('/该网站共有(.*?)个网页被百度收录/i',$bdsite,$count);
 
  if (!$count) preg_match('/找到相关结果数约(.*?)个/i',$bdsite,$count);
 
  //ereg('该网站共有(.*)个网页被百度收录', $bdsite,$count);
 
  //print_r($count);
 
  //$count=str_replace('该网站共有','',$count);
 
  //$count=str_replace('个网页被百度收录','',$count);
 
  $count = str_replace(array("\r\n", "\r", "\n", ',', ' '), '', $count);
 
  $baiduSL=strip_tags($count[1]);
 
  unset($count);
 
  return $baiduSL;
 
  }
 
  function BD_curl($url, $post=0, $referer=0, $cookie=0, $header=0, $ua=0, $nobaody=0){
 
  $ch = curl_init();
 
  $ip = rand(0,255).'.'.rand(0,255).'.'.rand(0,255).'.'.rand(0,255) ;
 
  curl_setopt($ch, CURLOPT_URL, $url);
 
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
 

(编辑:开发网_新乡站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!