python网站主动推送

2019-07-24 09:10:59来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

import requests
import random


def tuisong():
# urls用来存放需要推送的网站url,根据自己的实际网站数量添加
urls = {
'vc': '/urls?site=www.victorytestseo.com&token=k6V0Pq2c7BSmMgIb',
'fs': '/urls?site=www.firsttestseo.com&token=k6V0Pq2c7BSmMgIb',
'qc': '/urls?site=www.threetestseo.com&token=k6V0Pq2c7BSmMgIb',
'ws': '/urls?site=www.fourtestseo.com&token=k6V0Pq2c7BSmMgIb',
'jf': '/urls?site=www.jianfeiketang.com&token=k6V0Pq2c7BSmMgIb',
'yf': '/urls?site=www.maiclothes.com&token=k6V0Pq2c7BSmMgIb',
'ys': '/urls?site=www.maiclothes.com&token=k6V0Pq2c7BSmMgIb'
}
url = random.choice(list(urls.keys()))
input_choice = input('请输入要推送的网站:')
if input_choice == 'vc':
url = urls['vc']
filecontents = {'file': open('./vc.txt', 'rb')}
r = requests.post('http://data.zz.baidu.com' + url, files=filecontents)
baiduresult = "推送成功,结果为{}".format(r.text)
return baiduresult
elif input_choice == 'fs':
url = urls['fs']
filecontents = {'file': open('./fs.txt', 'rb')}
r = requests.post('http://data.zz.baidu.com' + url, files=filecontents)
baiduresult = "推送成功,结果为{}".format(r.text)
return baiduresult
elif input_choice == 'qc':
url = urls['qc']
filecontents = {'file': open('./qc.txt', 'rb')}
r = requests.post('http://data.zz.baidu.com' + url, files=filecontents)
baiduresult = "推送成功,结果为{}".format(r.text)
return baiduresult
elif input_choice == 'ws':
url = urls['ws']
filecontents = {'file': open('./ws.txt', 'rb')}
r = requests.post('http://data.zz.baidu.com' + url, files=filecontents)
baiduresult = "推送成功,结果为{}".format(r.text)
return baiduresult
elif input_choice == 'jf':
url = urls['jf']
filecontents = {'file': open('./jf.txt', 'rb')}
r = requests.post('http://data.zz.baidu.com' + url, files=filecontents)
baiduresult = "推送成功,结果为{}".format(r.text)
return baiduresult
elif input_choice == 'yf':
url = urls['yf']
filecontents = {'file': open('./yf.txt', 'rb')}
r = requests.post('http://data.zz.baidu.com' + url, files=filecontents)
baiduresult = "推送成功,结果为{}".format(r.text)
return baiduresult
elif input_choice == 'ys':
url = urls['ys']
filecontents = {'file': open('./ys.txt', 'rb')}
r = requests.post('http://data.zz.baidu.com' + url, files=filecontents)
baiduresult = "推送成功,结果为{}".format(r.text)
return baiduresult
elif input_choice == 'q':
exit()
else:
print('网址输入有误,请检查要推送的网站')


if __name__ == "__main__":
i = 0
while i < 5:
baidu = tuisong()
print(baidu)
i += 1

原文链接:https://www.cnblogs.com/victorstudy/p/11119663.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Python进阶:聊协程

下一篇:python学习-20 集合