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


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


    写了一个小东西记录baidu和google对于站点的收录情况,现在可以查询了,其实也没什么难度,就是去file下远程文件,然后分析下。
    对了貌似查google pr的东西只是file一个地址而已,如此说了就没有什么难度了。
    完整代码如下,file取得文件,分析,输出:

    <?php
    /**
    * 查询百度与谷歌收录
    * by www.jbxue.com
    * 2013-7-18
    */
    $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;
    }
    ?>
  • 相关阅读:
    MySQL 主主同步配置和主从配置步骤
    Nginx 禁止访问某个目录或文件的设置方法
    LNMP笔记:更改网站文件和MySQL数据库的存放目录
    centos最小安装 setuptools安装
    mkdir命令
    linux的mount(挂载)命令详解
    Java中wait()和notify()方法的使用
    剑指 offer面试题22 栈的压入和弹出序列
    剑指 offer面试题20 顺时针打印矩阵
    Leetcode 23.Merge Two Sorted Lists Merge K Sorted Lists
  • 原文地址:https://www.cnblogs.com/study100/p/3232349.html
Copyright © 2020-2023  润新知