今天分享给大家一款百度在线主动推送工具,替换自己的网站接口,就可以在线推送自己的站点内容给百度,实现快速收录,废话不说,上代码
把以下代码,在自己网站根目录或者其他目录新建一个baidu.php,复制以下代码保存为utf-8格式,即可在线运行
<?php error_reporting(E_ALL & ~ E_NOTICE);//屏蔽那些可以忽略的错误,如提示什么变量未定义 ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>百度收录提交</title> <meta name="viewport" content="target-densitydpi=medium-dpi, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"> <?php $result=""; if($_POST){ $content=$_POST["content"]; $finds = array("\r\n", "\n", "\r"); $fuhao = ','; $content=str_replace($finds, $fuhao, $content); $arr=explode(",", $content); $urls=array(); foreach($arr as $key=>$val){ if(trim($val)!=""){ $urls[]=trim($val); } } $postdata=implode("\n", $urls); $api = '替换你的接口'; $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => $postdata, CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); $result = curl_exec($ch); } ?> </head> <body> <form id="form1" name="form1" method="post" action=""> <label> <textarea name="content" style="height:200px;width:100%;">http://www.example.com/1.html http://www.example.com/2.html http://www.example.com/3.html http://www.example.com/4.html </textarea> </label> <p> <label> <input type="submit" name="Submit" value="提交" /> </label> </p> <div>结果: <textarea style="height:200px;width:100%;"><?php echo $result?></textarea> </div> </form> </body> </html>
演示地址:http://www.myjiancai.net/nav/baidu.php