本文實例講述了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( 找到相關網頁(.*)篇, , $site,$count); $count=str_replace( 找到相關網頁 , ,$count); $count=str_replace( 篇, , ,$count); $count=str_replace( 約 , ,$count); $count=str_replace( , , ,$count); return $count[0];echo baidu(www.jb51.net); //獲取腳本之家在百度中的收錄數量?
獲取百度的熱詞
?php * @return array 返回百度的熱詞數據(數組返回) 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());
這是在網上找的 稍微修改了下 將下面代碼寫入php文件
百度收錄和百度快照時間
?php $domain = //www.jb51.net/ *欲查詢的域名*/ $site_url = http://www.baidu.com/s?wd=site%3A $all = $site_url.$domain; /*域名所有收錄的網址*/ $today = $all. lm=1 /*域名今日收錄的網址*/ $utf_pattern = /找到相關結果數(.*)個/ $kz_pattern = / span >總結:以上就是本篇文的全部內容,希望能對大家的學習有所幫助。
相關推薦:
php實現多維數組的遍歷及unset刪除的方法
php實現針對文件的復制及移動的技巧
php基于采集類Snoopy實現抓取迅雷VIP賬號的方法
以上就是php抓取百度頁面及對應字符串的方法的詳細內容,PHP教程
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答