php实现查询百度google收录情况(示例代码)

2025-05-29 0 27

写了一个小东西记录baidu和google对于站点的收录情况,现在可以查询了,其实也没什么难度,就是去file下远程文件,然后分析下。

对了貌似查google pr的东西只是file一个地址而已,如此说了就没有什么难度了。
完整代码如下,file取得文件,分析,输出:

复制代码 代码如下:


<?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', '相关网页', '篇,用时');
getdetail($baidu_link, 'baidu_link', '相关网页', '篇,用时');
getdetail($baidu_domain, 'baidu_domain', '相关网页', '篇,用时');
}

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> 个结果,', ' 个。 (搜索用时');
getdetail($google_link, 'google_link', '<font size=-1>约有 <b>', '</b> 项链接到 <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;
}
?>

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 php实现查询百度google收录情况(示例代码) https://www.kuaiidc.com/107156.html

相关文章

发表评论
暂无评论