1. 程式人生 > 其它 >百度線上主動推送工具,實現快速收錄

百度線上主動推送工具,實現快速收錄

今天分享給大家一款百度線上主動推送工具,替換自己的網站介面,就可以線上推送自己的站點內容給百度,實現快速收錄,廢話不說,上程式碼

把以下程式碼,在自己網站根目錄或者其他目錄新建一個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

千行程式碼,Bug何處藏。 縱使上線又怎樣,朝令改,夕斷腸。