吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2554|回复: 2
收起左侧

[Python 转载] 羊了个羊通关加速多线程Python

  [复制链接]
52yy1150 发表于 2022-9-17 13:07
本帖最后由 52yy1150 于 2022-9-17 19:10 编辑

羊了个羊最近调整了服务器策略哦,过关接口有一点点慢,我们通过python脚本的多线程加速一下请求过程。
[Python] 纯文本查看 复制代码
from multiprocessing import Pool
import requests


def get():
    url = f"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"
    headers = {
        'Host': 'cat-match.easygame2021.com',
        'Connection': 'keep - alive',
        'charset': 'utf - 8',
        't': '你爬取的token',
        'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.28(0x18001c25) NetType/WIFI Language/en',
        'content-type': 'application/json',
        'Accept-Encoding': 'gzip, compress, br, deflate',
        'Referer': 'https://servicewechat.com/wx141bfb9b73c970a9/16/page-frame.html'
    }
    response = requests.get(url, headers=headers, timeout=5)
    return response.status_code


# 按间距中的绿色按钮以运行脚本。
if __name__ == '__main__':
    # 8表示现场池容量,酌情设置
    pool = Pool(8)
    # range100 表示请求次数
    for index in range(0, 100):
        if index % 10 == 0:
            print(index)
        pool.apply_async(get)
    pool.close()
    pool.join()

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

1120996628 发表于 2022-9-17 16:05
z这代码怎么执行
willgoon 发表于 2022-9-17 16:13
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-16 22:47

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表