代码如下:
# !/usr/bin/env python
# -*- coding:utf-8 -*-
"""
----------------------------------------
@所属项目 : Test
----------------------------------------
@作者 : French<1109527533@hoime.cn>
@软件 : PyCharm
@文件名 : ASheep.py
@创建时间 : 2022-9-19 - 15:09
@修改时间 : 2022-9-19 - 15:09
@文件说明 :
"""
import time
import json
import requests
import threading
class BrushSheep(object):
def __init__(self, uid):
self.uid = uid
self.token = None
self.frequency = 0
def obtain_token(self):
print("--------正在获取Token--------")
request_url = "http://103.222.188.236:66/api.php?act=yangGetToken"
request_data = {
"uid": self.uid
}
token_headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}
response = requests.post(url=request_url, data=request_data, headers=token_headers)
print(response)
response.encoding = "UTF-8"
response = json.loads(response.text)
if response["code"] == 0:
self.token = response["token"]
print("--------Token获取成功--------")
else:
print("Token获取失败, 等待重新获取")
time.sleep(3)
self.obtain_token()
def brush(self):
request_url = "https://cat-match.easygame2021.com/sheep/v1/game/game_over?" \
"rank_score=1" \
"&rank_state=1" \
"&rank_time=0" \
"&rank_role=2" \
"&skin=1" \
"&t=" + self.token + \
"&content-type=application/json" \
"&User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
while True:
self.frequency += 1
response = requests.get(url=request_url)
response.encoding = "UTF-8"
response = json.loads(response.text)
if response["err_code"] == 0:
print("第{}次刷取, 成功".format(self.frequency))
else:
print("第{}次刷取, 失败".format(self.frequency))
def start(self):
self.obtain_token()
test1 = threading.Thread(target=self.brush, name="test1")
test2 = threading.Thread(target=self.brush, name="test2")
test3 = threading.Thread(target=self.brush, name="test3")
test4 = threading.Thread(target=self.brush, name="test4")
test5 = threading.Thread(target=self.brush, name="test5")
test1.start()
test2.start()
test3.start()
test4.start()
test5.start()
print(threading.active_count())
if __name__ == '__main__':
test = BrushSheep(uid="37206376")
test.start()
运行结果
文章评论