這段程式碼是取得百度收錄量的!需要怎麼設定才能取得百度快照旁邊的網址呢?
chen
chen 2022-07-10 13:47:56
0
1
816

网页捕获_10-7-2022_134731_www.baidu.com.jpeg

<?php

/*

Plugin Name: XY-百度收錄量

Description: XY-根據域名返回百度收錄量

*/

$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($domain,$result,$ch);

function baiduSL ($domain) {

     $baidu='https://www.baidu.com/s?ie= utf-8&tn=baidu&wd=site:'.$domain; 

     $bdsite=BD_curl($baidu); 

     $bdsite = str_replace(array("\rn", " r", "\n", '    '), '', $bdsite); 

     if (!$count) preg_match('/找到相關結果數約(.*?)個/i', $bdsite,$count);

     $baiduSL=strip_tags($count[1]); 

     unset($count);

     return $baiduSL;## 

}

function BD_curl($url){

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B1431."

##    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $ret = curl_exec($ch);

    curl_close($ch); ret;

}

?>

chen
chen

全部回覆(1)
chen

麻煩各位了

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!