python-活动秒杀模板

python-活动秒杀模板源码

#-*- coding = utf-8 -*-
#Time : 2021/1/13 
#Author : 小柠檬
#File : 秒杀模板.py
import gevent.pool
import gevent.monkey
gevent.monkey.patch_all()
import requests
import json
import time
import threading

def lottery(a):
    url = 'https://iosapi.peiyinxiu.com/Api/User/OpenTask?addGold=1500&appkey=8b232b5997100d5a&taskId=20&token=8ce65ae7b582e0c0051125c0fd30da23&type=0&userId=164046973&sign=b9ee037c1ac5db2860999025683ca754'
    headers = {'User-Agent': 'dubbingshow/9.20.974/84c1be1a9909602db6746f02fd851d92(iPhone 6s;iOS13.1.2;750*1334)/164046388'}
    cookies = {'Cookie': 'Hm_lvt_0ce3585f47fda4b00bdda05866a55839=1610022693,1610023112,1610037170,1610037185'}

    try:
        r = requests.post(url, headers=headers,cookies=cookies)
        print(r.text)

    except Exception as e:
        print(e)

def geventMain(coroutinesNum):
    pool = gevent.pool.Pool()
    pool.map(lottery, (i for i in range(coroutinesNum)))

def threadMain(coroutinesNum):
    t = threading.Thread(target=geventMain,args=(coroutinesNum,))
    t.start()

if __name__ == '__main__':
    coroutinesNum = int(input('请输入协程数:'))
    count = int(input('请输入循环轮数:'))
    delay = float(input('请输入循环延迟(秒):'))
    times = input('请输入定时时间(00:00:00):')

    print('-'*10,'详细信息','-'*10)
    print('协程数:',coroutinesNum)
    print('循环轮数:',count)
    print('延迟(秒):',delay)
    print('定时时间:',times)
    print('-' * 10, '详细信息', '-' * 10)

    while True:
        print('\r',time.strftime('%H:%M:%S'),end='')
        if time.strftime('%H:%M:%S') == times:
            print()
            for i in range(count):
                threadMain(coroutinesNum)
                time.sleep(delay)

            break

        time.sleep(0.3)

    time.sleep(60)
    print('抽奖完成!')
    input('按下回车结束程序...')
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值