PHP implementation of querying Baidu and Google inclusion status (sample code)_PHP tutorial

WBOY
Release: 2016-07-21 15:00:00
Original
1029 people have browsed it

I wrote a small thing to record the inclusion status of the site by Baidu and Google. Now I can query it. In fact, it is not difficult. I just go to file and download the remote file, and then analyze it.

By the way, it seems that the thing you need to check Google PR is just a file address, so it’s not difficult at all.
The complete code is as follows, file obtains the file, analyzes and outputs:

Copy the code The code is as follows:

$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 web pages', 'Articles, time spent');
getdetail($baidu_link, 'baidu_link', 'Related web pages', 'Articles, time spent');
getdetail( $baidu_domain, 'baidu_domain', 'related web pages', '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', ' link to '); //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;
}
?> ;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328091.htmlTechArticleI wrote a small thing to record the inclusion status of the site by Baidu and Google. Now you can query it. In fact, it is not difficult. , just go to the remote file under file, and then analyze it. By the way, it seems...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template