小吉 发表于 2022-9-18 20:01:36

羊了个羊多线程刷次数

代码基本都是copy的,只是加了多线程,默认50,纯属来凑热闹
作者hecoter
import json
import requests
from threading import Thread
from queue import Queue

q = Queue(100000)

headers = {
    "user-agent": "Mozilla/5.0 (Linux; Android 10; HD1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/4309 MMWEBSDK/20220303 Mobile Safari/537.36 MMWEBID/583 MicroMessenger/8.0.21.2120(0x280015F0) Process/appbrand1 WeChat/arm64 Weixin NetType/4G Language/zh_CN ABI/arm64 MiniProgramEnv/android"
}
times = 0


class Consumer(Thread):
    def __init__(self):
      Thread.__init__(self)
      self.headers = headers

    def run(self):
      while True:
            try:
                self.join_pass()
            except:
                pass

    def join_pass(self, ):
      url1 = "https://cat-match.easygame2021.com/sheep/v1/game/topic_game_over?rank_score=1&rank_state=1&rank_time=1&rank_role=1&skin=1"
      res1 = requests.get(url1, headers=headers)
      url2 = "https://cat-match.easygame2021.com/sheep/v1/game/game_over?rank_score=1&rank_state=1&rank_time=1&rank_role=1&skin=1"
      res2 = requests.get(url2, headers=headers)
      global times
      times = times + 1
      print(f'已刷:{times} 次')


def getToken(uid):
    # 获取Openid
    try:
      headers = {
            'Accept': '*/*',
            'Accept-Encoding': 'gzip,compress,br,deflate',
            'Connection': 'keep-alive',
            'content-type': 'application/json',
            'Referer': 'https://servicewechat.com/wx141bfb9b73c970a9/16/page-frame.html',
            'User-Agent': 'Mozilla/5.0 (Linux; Android 12; M2012K11C Build/SKQ1.211006.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/4313 MMWEBSDK/20220805 Mobile Safari/537.36 MMWEBID/4629 MicroMessenger/8.0.27.2220(0x28001B37) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
            't': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTQ1MDI0NDUsIm5iZiI6MTY2MzQwMDI0NSwiaWF0IjoxNjYzMzk4NDQ1LCJqdGkiOiJDTTpjYXRfbWF0Y2g6bHQxMjM0NTYiLCJvcGVuX2lkIjoiIiwidWlkIjo0NTk0MjYwMiwiZGVidWciOiIiLCJsYW5nIjoiIn0.1lXIcb1WL_SdsXG5N_i1drjjACRhRZUS2uadHlT6zIY'
      }
      resp = requests.get(f"https://cat-match.easygame2021.com/sheep/v1/game/user_info?uid={uid}", headers=headers)
      if resp.status_code == 200 and 'wx_open_id' in resp.text:
            res = resp.json()
            openid = res['data']['wx_open_id']
            data = {
                "uuid": openid
            }
            resp = requests.post("https://cat-match.easygame2021.com/sheep/v1/user/login_tourist",
                                 data=json.dumps(data),
                                 headers=headers).json()
            token = resp['data']['token']
            return token
      else:
            return False
    except Exception as e:
      return False


if __name__ == '__main__':
    uid = input('输入uid:')
    while True:
      token = getToken(uid)
      if token != False:
            print(token)
            break
    headers['t'] = token
    for i in range(50):
      t = Consumer()
      t.start()

页: [1]
查看完整版本: 羊了个羊多线程刷次数