# Source: https://gitee.com/yangro/ql/blob/main/bak/fsy.py
# Raw: https://gitee.com/yangro/ql/raw/main/bak/fsy.py
# Repo: yangro/ql
# Path: bak/fsy.py
# UploadedAt: 2023-10-25T14:45:53+08:00
# SHA256: f99f91e7e71cda651e967f304000943db987d62e027a7b49d8c7036a94f83685
# Category: web版/抓包
# Evidence: web/H5关键词 + cookie/token/header

# coding=utf-8
"""
每日8:30
cron: 0 30 7 * * ?
new Env("飞速云机场")
"""
import requests
import utils.db as DB
import utils.tool as TOOL

global msg

msg = """
名称|状态
:--:|:--:
"""
mysql = DB.mysql()


def main():
    dbUser = mysql.select_all("select * from tb_fsy where status = 0")
    print("🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉\n")
    print("获取到: "+str(len(dbUser))+" 个用户")
    print("-------------------------------------------")

    for user in dbUser:
        signIn(user)


# 签到
def signIn(user):
    global msg
    url = 'https://feisu261.xyz/user/checkin'
    data = " "
    headers =  {
        "Host": "feisu261.xyz",
        "accept": "application/json, text/javascript, */*; q=0.01",
        "origin": "https://feisu261.xyz",
        "x-requested-with": "XMLHttpRequest",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/79.0.3945.147 Safari/534.24 XiaoMi/MiuiBrowser/14.3.21",
        "sec-fetch-site": "same-origin",
        "sec-fetch-mode": "cors",
        "referer": "https://feisu261.xyz/user",
        "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
        "cookie": user['cookie']
    }
    res = requests.post(url=url, data=data,headers=headers)
    json = res.json()

    print(user['user_name'] + " ---> " + json['msg'] +"\n")
    msg += user['user_name'] + "|" + json['msg'] + "\n\n"
    
    
    print("-------------------------------------------\n")


main()

# 一定要关闭数据库
print("🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉")
mysql.close()

TOOL.msgSend("b5fd9aaa249242e3aea2ca4bbebb6bfa", " ", msg, True)
