其他分享
首页 > 其他分享> > 荒野行动游戏代领爬虫

荒野行动游戏代领爬虫

作者:互联网

import requests
import re

code=input('请输入本次兑换码:')
# 使用readline()读文件
f = open("pcid.txt",encoding='utf-8')
tcnt=0
fcnt=0
while True:
line = f.readline()
if line:
uid = line.strip()
url = 'https://com-sev.webapp.163.com/g83nacdkey_query_uidinfo/api?callback=jQuery111309970743014941181_1654474258647&search_key={}&hostnum=10005&type=uid&_=1654474258648'.format(uid)
headers = {
'cookie': 'NTES_P_UTID=2e7UywW0Y2J7T4QirjM1JR9oPlU6Hibj|1654229681',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'
}
req1 = requests.get(url = url ,headers = headers)
if 'true' in req1.text:
role_id = re.findall('"role_id": "(.*?)"}], "role',req1.text)[0]
#print(id,role_id)
#step2
#code='k42ld6ja6'
url2 = 'https://com-sev.webapp.163.com/g83nacdkey_redeem/api?callback=jQuery111309970743014941181_1654474258647&role_id={}&hostnum=10005&code={}&gameid=g83naxx2gb&_=1654474258649'.format(role_id,code)
req2 = requests.get(url = url2,headers = headers)
#print(req2.text)
if 'false' in req2.text:
print('id:'+ uid +',玩家'+role_id+'领取失败!')
fcnt+=1

else:
print('id:'+ uid +',玩家'+role_id+'领取成功!')
tcnt+=1
#print('输入任意值退出...')
else:
print(uid,'id查询失败!!!')


else:
print('领取完成!!!成功领取'+str(tcnt)+'个,'+str(fcnt)+'个领取失败')
break
f.close()

标签:code,uid,爬虫,代领,headers,role,print,荒野,id
来源: https://www.cnblogs.com/AubeLiang/p/16379457.html