運(yùn)行百度站長(zhǎng)推送php,即可每天向百度推送url,加快收錄。但是要獲取url是個(gè)問(wèn)題,無(wú)奈之后自己用原生php獲取url并推送,僅供參考!
根目錄下建立geturl.php 代碼如下:
<?php
$config=include("application/database.php");
$hostname = $config['hostname'];
$username = $config['username'];
$password = $config['password'];
$dbname= $config['database'];
$web="你的網(wǎng)址";//注意修改為自己的
$conn = mysqli_connect($hostname, $username, $password, $dbname);
mysqli_query($conn,"SET NAMES UTF8");
$result = mysqli_query($conn,"select aid,typeid from ey_archives where author != '' order by rand() limit 100");
$num=mysqli_num_rows($result);
$urls=[];
for ($i=0; $i <$num ; $i++)
{
$row=mysqli_fetch_array($result);
$typeid=$row['typeid'];
$sql="select dirpath FROM ey_arctype where id={$typeid}";
$result1 = mysqli_query($conn,$sql);
$row1=mysqli_fetch_row($result1);
$urls[]= $web.$row1[0].'/'.$row['aid'].'.html'; //拼接url,根據(jù)實(shí)際情況調(diào)整
}
?>
根目錄下建立tuisong.php 代碼如下:
<?php
include ("1.php");
$api = 'http://data.zz.baidu.com/urls?site=你的網(wǎng)址&token=你的token';
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode("\n", $urls),
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;
?>
運(yùn)行 你的網(wǎng)址/tuisong.php 即可推送給百度100條url。
如有問(wèn)題請(qǐng)咨詢q:960263547