python网站主动推送
程序员文章站
2022-06-17 08:55:56
import requestsimport randomdef tuisong(): # urls用来存放需要推送的网站url,根据自己的实际网站数量添加 urls = { 'vc': '/urls?site=www.victorytestseo.com&token=k6V0Pq2c7BSmMgIb ......
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
上一篇: Python实现简单猜拳游戏