链接提交,主动推送百度站长平台,自动提交 Url ,shell+php+apache

seo们在工作过程中,经常需要从sitemap里面提取url,提交百度站长平台,那么今天我们就来看看,如何用shell+php+apache 做一个自动url Ping 提交百度站长平台。

shell 部分

前期准备:一个虚拟机,或linux,然后我们来一段优雅的shell。获得sitemap 的url。

第一步,获得sitemap索引文件中,所有的sitemap文件,并保存到1.txt。如下:

curl -s http://www.woshiseo.com/sitemap.xml sleep 1|grep -F -A 1 ‘<loc>’|sed ‘s/<[^<>]*>//g’|sed ‘s/–.*//g’|sed ‘s/2017.*//g’|sed ‘s/^[ \t]*//g’|sed -e ‘/^$/d’>>1.txt;echo ‘is done’;

以上引用部分,将sitemap中的所有sitemap文件,并保存到1.txt中,第一步就ok了。注意:2017这里是sitemap中的lastmod 的时间,如果你是其他时间请自行修改。

第二步,从所有sitemap文件中获取,所有的url。

for i in `cat 1.txt`;do curl -s $i sleep 1|grep -F -A 1 ‘<loc>’|sed ‘s/<[^<>]*>//g’|sed ‘s/–.*//g’|sed ‘s/2017.*//g’|sed ‘s/^[ \t]*//g’|sed -e ‘/^$/d’>>url.txt echo ‘is done’;done;

上文中 1.txt 需要把sitemap的主索引url先获取到。例如:

http://www.woshiseo.com/post/x

http://www.woshiseo.com/post/x1

http://www.woshiseo.com/post/x2

url.txt,就是所有的url地址。 继续阅读“链接提交,主动推送百度站长平台,自动提交 Url ,shell+php+apache”