Php: how to get Baidu record, Baidu buzzword, and Baidu snapshot, php Baidu snapshot _ PHP Tutorial

Source: Internet
Author: User
The php method for obtaining Baidu's indexing, Baidu's buzzwords, and Baidu's snapshot, and php's Baidu snapshot. Php: how to get Baidu record, Baidu keyword, and Baidu snapshot. php Baidu snapshot this article describes how to get Baidu record, Baidu keyword, and Baidu snapshot by php. I would like to share with you how to use php to obtain Baidu, Baidu buzzwords, and Baidu snapshots, and php Baidu snapshots.

This example describes how php can obtain Baidu's record, Baidu's buzzword, and Baidu's snapshot. Share it with you for your reference. The details are as follows:

Get Baidu record:

<? Php/* capture baidu indexed code */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 ("locate related webpage (. *), ", $ site, $ count); $ count = str_replace (" find related webpage "," ", $ count); $ count = str_replace, "," ", $ count); $ count = str_replace (" approx "," ", $ count); $ count = str_replace (",","", $ count); return $ count [0];} echo baidu (www.jb51.net); // Obtain the number of items included by the customer's home in baidu?>

Get Baidu's buzzwords

<? Php/*** @ return array return Baidu's popular word data (array return) */function getBaiduHotKeyWord () {$ templateRss = file_get_contents ('http: // top.baidu.com/rss_xml.php? P = top10'); if (preg_match ('/

This is a slight modification found on the internet. write the following code into the php file.
Baidu record and Baidu snapshot time

<? Php $ domain = "http://www.bkjia.com/* domain name to query */$ site_url = 'http: // www.baidu.com/s? Wd = site % 3A '; $ all = $ site_url. $ domain;/* all URLs included in the domain name */$ today = $ all. '& lm = 1';/* domain name's URL indexed today */$ utf_pattern = "/find the number of results (. *)/"; $ kz_pattern = "/(. *)/";/* string used to match the snapshot date */$ times ="/d {4}-d {1, 2}-d {1, 2 }/"; /* match the regular expression of the snapshot date, for example, 2011-8-4 */$ s0 = @ file_get_contents ($ all);/* Change site: put the webpage www.jb51.net into the $ s0 string */$ s1 = @ file_get_contents ($ today); preg_match ($ utf_pattern, $ s0, $ all_num ); /* match "find the number of related results *" */preg_match ($ utf_pa Ttern, $ s1, $ today_num); preg_match ($ kz_pattern, $ s0, $ temp); preg_match ($ times, $ temp [0], $ screenshot ); if ($ all_num [1] = "") $ all_num [1] = 0; if ($ today_num [1] = "") $ today_num [1] = 0; if ($ screenshot [0] = "") $ screenshot [0] = "no snapshot";?>    Test   
(. *) <\/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-> a) ;}} return $ keyArray ;} print_r (getBaiduHotKeyWord ());
Date Baidu Baidu recorded today Baidu snapshot date
<? Php echo date ('m month D Day G time');?> <? Php echo $ all_num [1];?> <? Php echo $ today_num [1];?> <? Php echo $ screenshot [0];?>

Baidu: "target =" _ blank "> <? Php echo $ all_num [1];?>

Baidu recorded today: "target =" _ blank "> <? Php echo $ today_num [1];?>

Baidu snapshot date: "> <? Php echo $ screenshot [0];?>

I hope this article will help you with php programming.

Examples in this article describe how php obtains Baidu's record, Baidu's buzzwords, and Baidu's snapshots. Share it with you...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.