神马搜索api推送收录python代码

本文介绍了如何使用Python实现神马搜索的API自动推送收录功能。首先,通过生成sitemap.xml文件的链接列表txt文本,然后使用Python代码调用神马搜索的API进行推送提交。
摘要由CSDN通过智能技术生成

百度收录api推送方法请看上一篇文章:https://blog.csdn.net/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
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值