欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php 百度快照、百度收录、百度热词的代码分享

程序员文章站 2022-04-20 22:42:02
...
本文分享几段php代码,分别用于获取百度快照时间、百度收录情况、百度热词。有需要的朋友作个参考。

用php获取百度快照、百度收录、百度热词,供大家参考。

1,获取百度收录


/*
* 百度收录
* $s 为要查询的网站域名
* by bbs.it-home.org
*/
function baidu($s){
  $baidu="http://www.baidu.com/s?wd=site%3A".$s;
  $site=file_get_contents($baidu);
  //$site=iconv("gb2312", "UTF-8", $site);
  ereg("找到相关网页(.*)篇,", $site,$count);
  $count=str_replace("找到相关网页","",$count);
  $count=str_replace("篇,","",$count);
  $count=str_replace("约","",$count);
  $count=str_replace(",","",$count);
  return $count[0];
}
echo baidu(bbs.it-home.org); //获取好主题在百度中的收录数量
?>

2,获取百度的热词

(.*)
/is', $templateRss, $_description)) { $templateRss = $_description [0]; $templateRss = str_replace("&", "&", $templateRss); } $templateRss = "" . $templateRss; $xml = simplexml_load_String($templateRss); foreach ($xml->tbody->tr as $temp) { if (!empty ($temp->td->a)) { $keyArray [] = trim(($temp->td->a)); } } return $keyArray; } print_r(getBaiduHotKeyWord()); ?>

3,百度收录和百度快照时间

(.*)