今天分享給大家一款百度在線主動推送工具,替換自己的網站接口,就可以在線推送自己的站點內容給百度,實現快速收錄,廢話不說,上代碼
把以下代碼,在自己網站根目錄或者其他目錄新建一個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>