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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#coding:utf-8 import requests import time from bs4 import BeautifulSoup as bp print ('自动推送开启....','utf-8') time.sleep(0.5) # your sitemap file url site_url = '自己的网站地图' try: print ('正在获取sitemap链接....','utf-8') data_ = bp(requests.get(site_url).content,'lxml') except Exception.e: print (e) list_url=[] def get_(data): headers= { 'User-Agent': 'curl/7.12.1', 'Host': 'data.zz.baidu.com', 'Content-Type': 'text/plain', 'Content-Length': '83' } try: r = requests.post(url='自己的api地址',data=data) print (r.status_code) print (r.content) except Exception as e: print (e) print ('---------------------------------') for x,y in enumerate(data_.find_all('loc')): print ( x,y.string) list_url.append(y.string.replace('http://','http://')) print ('---------------------------------') print ('链接开始推送....','utf-8') for x in list_url: print ('当前推送条目为:',x) get_(x) |
脚本百分之百没问题,如遇问题请 查看日志,自行解决。
阅读全文
评论前必须登录!
立即登录 注册