PHP implementation query Baidu Google included cases (sample code) _php Skills

Source: Internet
Author: User

Wrote a small thing to record Baidu and Google for the site included, now can query, in fact, it is not difficult, is to file the remote files, and then analysis.

Yes, looks like Google PR thing is just a file address, so said there is no difficulty.
The complete code is as follows, file obtains the document, analyzes, outputs:

Copy Code code as follows:

<?php
$seodetail = Array ();
$domain =!empty ($_get[' Q '])? $_get[' Q ']: ' www.mycodes.net ';
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 ', ' related pages ', ' articles, when ');
    Getdetail ($baidu _link, ' baidu_link ', ' related pages ', ' articles, when ');
    Getdetail ($baidu _domain, ' baidu_domain ', ' related pages ', ' articles, when ');
}

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 ', ' </b> results, ', '. (In search of ");
Getdetail ($google _link, ' google_link ', ' <font size=-1> about <b> ', ' </b> necklace received <b> '); 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.