Php allows you to query Baidu and google records (sample code)

Source: Internet
Author: User
I wrote a small item to record the indexing of the site by baidu and google. now I can query it. In fact, there is no difficulty. I just need to go to the file to get a remote file and analyze it. By the way, it seems that the query of googlepr is just an address of file, so there is no difficulty in writing a small item to record the indexing of the site by baidu and google. now you can query it, in fact, there is no difficulty, that is, to go to the file for a remote file, and then analyze it.

By the way, it seems that google pr is only an address of file, so there is no difficulty.
The complete code is as follows. file is used to obtain, analyze, and output files:

The code is as follows:


$ Seodetail = array ();
$ Domain =! Empty ($ _ GET ['Q'])? $ _ GET ['Q']: 'www .bitscn.com;
Baidudetail ($ domain );
Googledetail ($ domain );
Var_dump ($ seodetail );

Function baidudetail ($ domain ){
$ Baidu_site = 'http: // www.baidu.com/baidu? Word = site % 3A '. $ domain;
$ Baidu_link = 'http: // www.baidu.com/baidu? Word = link % 3A '. $ domain;
$ Baidu_domain = 'http: // www.baidu.com/baidu? Word = domain % 3A '. $ domain;
Getdetail ($ baidu_site, 'Baidu _ site', 'webpage related ', 'article, Time ');
Getdetail ($ baidu_link, 'Baidu _ link', 'webpage related ', 'article, Time ');
Getdetail ($ baidu_domain, 'Baidu _ domain ', 'webpage related', 'article, Time ');
}

Function googledetail ($ domain ){
$ Google_site = 'http: // www.google.cn/search? Hl = zh-CN & q = site % 3A '. $ domain;
$ Google_link = 'http: // www.google.cn/search? Hl = zh-CN & q = link % 3A '. $ domain;
Getdetail ($ google_site, 'Google _ site ','Results. (Search time ');
Getdetail ($ google_link, 'Google _ link', 'about','Necklace receipt'); // 102
}

Function getdetail ($ url, $ type, $ wordf, $ wordb ){
$ Pagecontent = @ file ($ url );
$ Pagecontent = implode ('', $ pagecontent );
$ Pagecontent = substr (strstr ($ pagecontent, $ wordf), strlen ($ wordf ));
$ Pagecontent = substr_replace ($ pagecontent, '', strpos ($ pagecontent, $ wordb ));
Returndetail ($ pagecontent, $ type );
}

Function returndetail ($ content, $ type ){
Global $ seodetail;
$ Seodetail [$ type] = empty ($ content )? 0: $ content;
}
?>

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.