Home >Backend Development >PHP Tutorial >Check Baidu—Baidu website weight SEO tool query_PHP tutorial
Check Baidu—Baidu website weight SEO tool query
And you can find out which page your webpage is ranked on. If the ranking is poor, you can consider refining your website appropriately.
function get_microtime()
{ list($usec, $sec) = explode(" ",microtime());
return ((float )$usec + (float)$sec);
}
$time_start = get_microtime();
set_time_limit(0);
$kw=$_GET["kw"];
$url=$_GET["url"];
$ depth=$_GET["depth"];
$next=1;$pn=0;$flag=0;$n=1;$ps tutorial=0;
$baseurl="http:// www.baidu.com/s?";
$kw=str_replace("+","%2B",$kw);
$kw=str_replace(" ","%20",$kw) ;
if($depth==""||$depth<=0) $depth=10;
if($depth>76) $depth=76;
echo "
while($next==1)
{
$baidu_url=$baseurl."lm=0&si=&rn=10&tn=wangcong&ie=gb2312&ct=0&wd=".$kw."&pn=".$pn ."&cl=3";
$str=file_get_contents($baidu_url);
$baidu_url=str_replace("%20","+",$baidu_url);
if(strpos( $str,$url))
{
if($n==1) echo "Search for keywords in Baidu:'".$kw."', from The results of '".$url."' are:
";
$pagenum=$pn/10+1;
echo "< ;br> The ".$n." result, ";
echo ", is ranked ".$pagenum." in the Baidu search results. ";
echo "
";
echo " Click here to view";
echo "
" ;
$flag=1;
$n=$n+1;
}
$pn=$pn+10;
$ps=$ps+1;
if($ps==$depth) $next=0;
if(!strpos($str,"Next page")) $next=0 ; //Judge whether there is a next page;
}
$time_end = get_microtime();
$time = $time_end - $time_start;
if($flag==0) echo "
No results from ".$url." were found under the current depth conditions. Your optimization needs to be improved. You can try to increase the query depth.< ;br>
";
$n=$n-1;
echo "
Statistics:A total of ".$ ps." page, found ".$n." related results, time consumption: ".$time." seconds.
";
?>