想要在根目录下写个调取100条内容URL,怎么写?

作者:admin 分类:eyoucms使用教程 时间:2023-07-24 浏览:

(图1)

想获取100条URL主动推送给百度,可以在根目录下写个调取100条内容URL的php文件,具体写法如下


geturl.php

<?php

$config=include("application/database.php");

$hostname = $config['hostname'];

$username = $config['username'];

$password = $config['password'];

$dbname= $config['database'];

$web="你的网址";

$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,并存入数组

  }

?>


tuisong.php

<?php

include ("geturl.php");

$api = 'http://data.zz.baidu.com/urls?site=你的网站&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;

?>

都放在网站根目录下


文章链接:https://www.eyhtml.com/xinwendongtai/434.html
文章标题:想要在根目录下写个调取100条内容URL,怎么写?
文章版权:所发布的内容,部分为原创文章,转载请注明来源,网络转载文章如有侵权请联系我们!
本文最后更新发布于2023-07-24

相关阅读

温馨提示
新春特惠活动持续至马年元宵节
月费会员只要19元,终身会员原价299,现价只要99元。终身会员商业模板5折出售,最近大量模板陆续上新中!
我要查看