本文實例講述了php獲取百度收錄、百度熱詞及百度快照的方法。具體如下:
獲取百度收錄:
?php抓取百度收錄代碼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( 找到相關(guān)網(wǎng)頁(.*)篇, , $site,$count); $count=str_replace( 找到相關(guān)網(wǎng)頁 , ,$count); $count=str_replace( 篇, , ,$count); $count=str_replace( 約 , ,$count); $count=str_replace( , , ,$count); return $count[0];echo baidu(www.jb51.net); //獲取腳本之家在百度中的收錄數(shù)量?
獲取百度的熱詞
?php * @return array 返回百度的熱詞數(shù)據(jù)(數(shù)組返回) function getBaiduHotKeyWord()$templateRss = file_get_contents( http://top.baidu.com/rss_xml.php?p=top10 if (preg_match( / table (.*) //table /is , $templateRss, $_description)) {$templateRss = $_description [0];$templateRss = str_replace( , , $templateRss);$templateRss = ?xml version=1.0 encoding=GBK? . $templateRss;$xml = @simplexml_load_String($templateRss);foreach ($xml- tbody- tr as $temp) {if (!empty ($temp- td- a)) {$keyArray [] = trim(($temp- td- return $keyArray;print_r(getBaiduHotKeyWord());
這是在網(wǎng)上找的 稍微修改了下 將下面代碼寫入php文件
百度收錄和百度快照時間
?php $domain = //www.jb51.net/ *欲查詢的域名*/ $site_url = http://www.baidu.com/s?wd=site%3A $all = $site_url.$domain; /*域名所有收錄的網(wǎng)址*/ $today = $all. lm=1 /*域名今日收錄的網(wǎng)址*/ $utf_pattern = /找到相關(guān)結(jié)果數(shù)(.*)個/ $kz_pattern = / span >總結(jié):以上就是本篇文的全部內(nèi)容,希望能對大家的學(xué)習(xí)有所幫助。
相關(guān)推薦:
php實現(xiàn)多維數(shù)組的遍歷及unset刪除的方法
php實現(xiàn)針對文件的復(fù)制及移動的技巧
php基于采集類Snoopy實現(xiàn)抓取迅雷VIP賬號的方法
以上就是php抓取百度頁面及對應(yīng)字符串的方法的詳細(xì)內(nèi)容,PHP教程
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。
新聞熱點
疑難解答
圖片精選