
php 主动推送站点链接到百度站长,神马站长进行 SEO。
把需要提交的链接和各站长 api 分别放在两个 txt 文件里面,然后运行 php 文件进行提交,不同站长提交成功一般返回的都是 200 状态码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <?php //链接存放路径和站长 api 文件存放路径 $urls_path = "H:\\lruihao.cn\\public\\baidu_urls.txt"; $apis_path = "G:\\Demo\\lrh01\\zhanzhang_api.txt"; //将文件每一行读到一个数组里面去 $urls = file($urls_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $apis = file($apis_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); for($x=0;$x<count($apis);$x++){ $ch = curl_init(); $options = array( CURLOPT_URL => $apis[$x], 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 "API: <br/> ".$apis[$x]."<br/>"; echo "result: <br/> ".$result."<hr/>"; } ?> |
|---|
