百度收录api推送方法请看上一篇文章:https://blog.youkuaiyun.com/jlysx/article/details/113360294
神马搜索站长自动api推送收录代码方法,本文使用python。
先将网站根目录的sitemap.xml文件生成一条条链接的txt文本,再推送提交api到神马搜索。
1.新建py_url.py,代码如下:
#coding=utf-8
import urllib
import urllib.request
import re
url='http://www.budinghua.com/sitemap.xml'
html=urllib.request.urlopen(url).read()
html=html.decode('utf-8')
r=re.compile(r'(http://www.budinghua.com.*?\.html)')
big=re.findall(r,html)
clean_xml_txt=open("x:/xxx/xxx/WWW/sitemap.txt", 'w').close()
for j, i in enumerate(big):
print(i)
if j > 1:
op_xml_txt=open('x:/xxx/xxx/WWW/sitemap.txt','a')//新建txt
op_xml_txt.write('%s\n'%i)
生成txt之后,新建shenma.py文件推送
#coding:utf8
import requests