欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

python+txt参数化实现批量用户发奖

时间:2023-04-21

import codecsimport jsonimport requestssource = codecs.open("E:\testfile\performance\fajiang.txt", "r", "gb18030")values = source.readlines()phones = []users = []for val in values: phone, user = val.split(',') phone = phone.strip('trn') user = user.strip('trn') phones.append(phone) users.append(user)print(phones)print(users)headers = { "token" :"/", "User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.18(0x1800122c) NetType/WIFI Language/zh_CN", "Accept-Encoding":"gzip", "Accept-Language":"zh-CN,zh;q=0.9", "Content-Type":"application/json", "Content-Length":"129",}for phone in phones: data={ "codeCount":"20", "theGoods": [{"goodsName":"test","count":1}], "totalMoney":"120", "lotteryActivityId":54, "phone":phone } url = "发奖接口" luckyUrl = requests.post(url=url, data=json.dumps(data),headers=headers) with open('C:/Users/Lenovo/Desktop/choujiang/choujiang.txt', 'a+', encoding='utf-8') as f: print(luckyUrl.text, file=f) print('--------------------n', file=f) print(luckyUrl)

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。