学习资料1

import datetime
import json
from multiprocessing.pool import Pool

import requests

# 当前时间 用于计算卡密时间
nowTime = datetime.datetime.now()

# 目标
url = 'http://lol.021tc.pw/ajax.php?act=query'
url_detail = 'http://lol.021tc.pw/ajax.php?act=order'
# 数据表单
d = {'type': '0', 'qq': 'xx', 'page': '1'}
# 请求头
req_header = dict()
req_header['Accept'] = 'application/json, text/javascript, */*; q=0.01'
req_header['Accept-Encoding'] = 'gzip, deflate'
req_header['Cache-Control'] = 'no-cache'
req_header['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
req_header[
    'Cookie'] = 'PHPSESSID=1hci9fm7r0ojgt5jn35rqevlh2; sec_defend=12cb426e186acdf6802cf9371e25ba3ef35addf5500ba9d826734bc5af301b20; mysid=9548b0c4f5cbcfacec504f2e8b3911bf; op=false; counter=3'
req_header['Pragma'] = 'no-cache'
req_header[
    'User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.47'
req_header['X-Requested-With'] = 'XMLHttpRequest'
req_header['Referer'] = 'http://lol.021tc.pw/'
req_header['Origin'] = 'http://lol.021tc.pw'


# 单人数据爬取
def goSingle(form):
    # POST请求
    r = requests.post(url, headers=req_header, data=form, verify=False)

    reqStr = r.text
    reqJson = json.loads(reqStr)
    dataJson = json.loads(json.dumps(reqJson['data']))
    if dataJson:
        for i in dataJson:
            buyTime = datetime.datetime.strptime(i['addtime'], "%Y-%m-%d %H:%M:%S")
            expTime = (nowTime - buyTime).total_seconds() / 3600
            # 如果有则请求明细 并打印
            if expTime <= 24:
                dt = {'id': i['id'], 'skey': i['skey']}
                rt = requests.post(url_detail, headers=req_header, data=dt, verify=False)
                rtJson = json.loads(rt.text)
                with open(r'D:\Py_T\src\hack\res.txt', mode='a') as res:
                    print(("辅助:%s 时间:%s 消费:%s 卡密:%s 查询:%s 备注:%s\r" % (
                        rtJson['name'], rtJson['date'], rtJson['money'], rtJson['kminfo'], rtJson['inputs'],
                        rtJson['desc'])))
                    res.write("辅助:%s 时间:%s 消费:%s 卡密:%s 查询:%s 备注:%s\r" % (
                        rtJson['name'], rtJson['date'], rtJson['money'], rtJson['kminfo'], rtJson['inputs'],
                        rtJson['desc']))
            else:
                print("有记录qq但不小于两天:%s " % (form['qq']))
    else:
        print("无记录qq:%s" % (form['qq']))


if __name__ == '__main__':
    qqli = []
    with open(r'D:\Py_T\src\hack\res.txt', mode='w') as res:
        res.truncate()
        res.close()
    with open(r'D:\Py_T\src\hack\qq.txt', mode='r') as qf:
        for qq in qf:
            d['qq'] = qq.strip()
            qqli.append(d)
            d = {'type': '0', 'qq': 'xx', 'page': '1'}
    qf.close()
    pool = Pool(processes=4)
    result = pool.map(goSingle, qqli)
    pool.close()
    pool.join()

本脚本仅供学习参考,切勿用于非法用途,转载请注明来源

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

春马与夏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值