[python]摸鱼派自动签到

自动签到,花了几个小时,研究网站签到,图像处理用的别人的api,成了人民币玩家,经错半夜测试,已成功运行

废话不多说,直接上代码

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/10/27 18:01
# @Author  : Aen
# @File    : auto_login.py
# @Software: PyCharm
import base64
import datetime
import json
import time
import requests

headers = {
    'Connection': 'keep-alive',
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept - Encoding': 'gzip, deflate',
    'Accept - Language': 'zh - CN, zh;q = 0.9',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
    'Sec-Fetch-Site': 'same-origin',
    'Sec-Fetch-Mode': 'cors',
    'X-Requested-With': 'XMLHttpRequest',
    'Sec-Fetch-Dest': 'empty',
    'Referer': 'https://pwl.icu/',
    'Cookie': 'cookie'
}


def base64_api(uname, pwd, img, typeid):
    with open(img, 'rb') as f:
        base64_data = base64.b64encode(f.read())
        b64 = base64_data.decode()
    data = {"username": uname, "password": pwd, "typeid": typeid, "image": b64}
    result = json.loads(requests.post("http://api.ttshitu.com/predict", json=data).text)
    if result['success']:
        return result["data"]["result"]
    else:
        return result["message"]
    return ""


def auto_get_grade():
    # img_path = "/Users/aen/Desktop/captcha.png"
    # result = base64_api(uname='***', pwd='***', img=img_path, typeid=16)
    # print(result)
    session = requests.Session()
    url1 = 'https://pwl.icu/'
    url2 = 'https://pwl.icu/activity/daily-checkin-api/'
    img_path = "okk.png"
    download_url_tmp = 'https://pwl.icu/captcha?'
    pic_time = int(round(time.time() * 1000))
    download_url = download_url_tmp + str(pic_time)
    print('pic downloading')
    content_file = requests.get(url=download_url, headers=headers).content
    print(download_url)
    file_name = 'okk.png'
    with open(file_name, 'wb') as fp:
        fp.write(content_file)
        print(file_name, 'download successful')
    result = base64_api(uname='aeneag', pwd='Aen221909', img=img_path, typeid=16)
    url3 = url2 + str(result)
    print(url3)
    response = session.get(url=url3, headers=headers)
    print(response.text)
    back_json = json.loads(response.text)
    back_number = back_json['sum']
    return back_number


if __name__ == "__main__":
    count = 0
    while count < 4:
        time.sleep(2)
        res = auto_get_grade()
        count = count + 1
        if res == -1:
            print('已经签到了')
            with open('auto_login.log', 'a') as fp:
                fp.write(str(datetime.datetime.now()) + '     successful \n')
            break
    if count == 4:
        with open('auto_login.log', 'a') as fp:
            fp.write(str(datetime.datetime.now()) + '     failed \n')

    # if auto_get_grade() == -1:
    #     print('已经签到了')
    #     with open('auto_login.log', 'a') as fp:
    #         fp.write(str(datetime.datetime.now()) + '     successful \n')


    


公众号'艾恩凝'
个人公众号
个人微信
个人微信
    吾心信其可行,
          则移山填海之难,
                  终有成功之日!
                                  ——孙文
    评论
    0 评论
avatar

取消