seo的福音,运用ping指令实现主动吸引搜索引擎抓取,秒收不是梦

这个类的原理是运用ping指令,向百度,谷歌发送ping命令,吸引百度,谷歌蜘蛛抓取.

<?php
class ping {
 
    public $method, $callback;
 
    public function method($site_name, $site_url, $update_url, $update_rss) {
        $this->method = "
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  <methodCall>
    <methodName>weblogUpdates.extendedPing</methodName>
    <params>
   <param><value>{$site_name}</value></param>
   <param><value>{$site_url}</value></param>
   <param><value>{$update_url}</value></param>
   <param><value>{$update_rss}</value></param>
    </params>
  </methodCall>";
        return $this->method;
    }
 
    public function _post($url, $postvar) {
        $ch = curl_init();
        $headers = array(
            "POST " . $url . " HTTP/1.0",
            "Content-type: text/xml;charset=utf-8",
            "Accept: text/xml",
            "Content-length: " . strlen($postvar)
        );
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
        $res = curl_exec($ch);
        curl_close($ch);
        return $res;
    }
 
    public function google() {
        $this->callback = $this->_post('http://blogsearch.google.com/ping/RPC2', $this->method);
        return strpos($this->callback, "<boolean>0</boolean>") ? true : false;
    }
 
    public function baidu() {
        $this->callback = $this->_post('http://ping.baidu.com/ping/RPC2', $this->method);
        return strpos($this->callback, "<int>0</int>") ? true : false;
    }
 
}
$Ping=new Ping();
$Ping->method('好看影视网', 'http://www.haokanvideo.com', 'http://www.haokanvideo.com/detail-n/1.html', 'http://www.haokanvideo.com/maps/rss.xml');
//实际上就是文章的地址
$Ping->google() ;
$Ping->baidu();
echo "成功";
?>

注意:如果提示找不到curl_init(),那是因为没有在apache中开启服务,

打开php.ini,将 extension=php_curl.dll前的;去掉 重启apache

我的影视站:好看影视网

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值