From df3891a3d8fb7debe64470ac347a761c23714ab9 Mon Sep 17 00:00:00 2001 From: midpoint Date: Fri, 25 Oct 2024 19:03:44 +0800 Subject: [PATCH] Update main.py --- main.py | 125 ++++++++++++-------------------------------------------- 1 file changed, 25 insertions(+), 100 deletions(-) diff --git a/main.py b/main.py index b52dd22f..bea7325e 100644 --- a/main.py +++ b/main.py @@ -1,49 +1,12 @@ -# -------------------request-1----------------------------- -# { -# "appId": "wb182564874663h152492176", -# "b": "ce032b305a9bc1ce0b0dd2a", -# "c": "0723244023c072b030ba601", -# "ci": 60, -# "co": 336, -# "sm": "[插图]威慑纪元61年,执剑人在一棵巨树", -# "pr": 65, -# "rt": 30, -# "ts": 1727580275610, -# "rn": 869, -# "sg": "aefc57298e0796865d8609165c28958696779eda3649720bf0c55a9687ce247d", -# "ct": 1727580275, -# "ps": "48d32f007a4c133dg011052", -# "pc": "f69321d07a4c133dg01256e", -# "s": "93912b18" -# } import random - -# -------------------request-2----------------------------- -# { -# "appId": "wb182564874663h152492176", ✔ -# "b": "ce032b305a9bc1ce0b0dd2a", ✔ -# "c": "0723244023c072b030ba601", ✔ -# "ci": 60, ✔ -# "co": 336, ✔ -# "sm": "[插图]威慑纪元61年,执剑人在一棵巨树", ✔ -# "pr": 65, ✔ -# "rt": 88, ✔ -# "ts": 1727580815581, ✔ -# "rn": 114, -# "sg": "bfdf7de2fe1673546ca079e2f02b79b937901ef789ed5ae16e7b43fb9e22e724", -# "ct": 1727580815, ✔ -# "ps": "48d32f007a4c133dg011052", ✔ -# "pc": "f69321d07a4c133dg01256e", ✔ -# "s": "fadcb9de" -# } - import requests import json import time import hashlib import urllib.parse + +from config import headers,cookies from cookie import get_wr_skey -from push import push def encode_data(data, keys_to_include=None): @@ -76,72 +39,28 @@ def cal_hash(input_string): return hex(_7032f5 + _cc1055)[2:].lower() -headers = { - "accept": "application/json, text/plain, */*", - "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,ko;q=0.5", - "baggage": "sentry-environment=production,sentry-release=dev-1727596539903,sentry-public_key=ed67ed71f7804a038e898ba54bd66e44,sentry-trace_id=d3cc3a94f5244647b8064ecd77eb8ba6", - "cache-control": "no-cache", - "content-type": "application/json;charset=UTF-8", - "dnt": "1", - "origin": "https://weread.qq.com", - "pragma": "no-cache", - "priority": "u=1, i", - "referer": "https://weread.qq.com/web/reader/ce032b305a9bc1ce0b0dd2akd2d32c50249d2ddea18fb39", - "sec-ch-ua": "\"Microsoft Edge\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\"", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "\"Windows\"", - "sec-fetch-dest": "empty", - "sec-fetch-mode": "cors", - "sec-fetch-site": "same-origin", - "sentry-trace": "d3cc3a94f5244647b8064ecd77eb8ba6-93b39e13fa4e5fd6", - "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" -} -# 会话密钥 - -cookies = { - "RK": "oxEY1bTnXf", - "ptcz": "53e3b35a9486dd63c4d06430b05aa169402117fc407dc5cc9329b41e59f62e2b", - "pac_uid": "0_e63870bcecc18", - "iip": "0", - "_qimei_uuid42": "183070d3135100ee797b08bc922054dc3062834291", - "_qimei_fingerprint": "28ec521da86d1fbc149479d2aa40f951", - "_qimei_q36": "", - "_qimei_h38": "cb6de4e4797b08bc922054dc02000005818307", - "pgv_pvid": "1212703189", - "fqm_pvqid": "50bb40ea-985c-4d11-9cea-7dfefe6ea1ca", - "_clck": "15sxecs|1|fl1|0", - "qq_domain_video_guid_verify": "004329d456c0ef18", - "wr_vid": "346607432", - "wr_localvid": "6a8327b0814a8cf486a8884", - "wr_name": "%E6%9C%AC%20%E6%97%A0%20%E9%81%93", - "wr_gender": "1", - "wr_rt": "web%40dz_AYa7CIYk07_ucDIb_AL", - "wr_avatar": "https%3A%2F%2Fthirdwx.qlogo.cn%2Fmmopen%2Fvi_32%2FMCpyjIyiaHicBXjh38REzNMA1xXiaeoWJ321CicmRcyMzeSibgDp1z6XC1FVr4szNr4PUsfIqEPRNXa4l9h2NGQsZDg%2F132", - "wr_fp": "1659424119", - "wr_pf": "NaN", - "wr_skey": "ivnZkd2_" -} url = "https://weread.qq.com/web/book/read" data = { - "appId": "wb182564874663h152492176", - "b": "ce032b305a9bc1ce0b0dd2a", - "c": "7cb321502467cbbc409e62d", - "ci": 70, - "co": 0, - "sm": "[插图]第三部广播纪元7年,程心艾AA说", - "pr": 74, - "rt": 30, - "ts": 1727660516749, - "rn": 31, - "sg": "991118cc229871a5442993ecb08b5d2844d7f001dbad9a9bc7b2ecf73dc8db7e", - "ct": 1727660516, - "ps": "b1d32a307a4c3259g016b67", - "pc": "080327b07a4c3259g018787", + "appId": "wb182564874663h1736463455", + "b": "609427c3643425f425a36314a4531484244764f36726936744436416b3158691e4", + "c": "c81322c012c81e728d9d180", + "ci": 2, + "co": 643, + "sm": "图书在版编目(CIP)数据我与地坛/史铁", + "pr": 0, + "rt": 9, + "ts": 1729840344377, + "rn": 902, + "sg": "10a63e47c3a337c129375854161f639d89f50f98999bdfcdd78d72b2807a5cdf", + "ct": 1729840344, + "ps": "f8732c107a4f86e1g013d29", + "pc": "25a324107a4f86e1g014dd4", } # 加密盐 key = "3c5c8717f3daf09iop3423zafeqoi" num = 1 +errnum = 0 while True: # 处理数据 @@ -167,13 +86,19 @@ def cal_hash(input_string): num += 1 time.sleep(30) else: - print("数据格式问题,尝试初始化cookie值") + print("数据格式问题,异常退出!") cookies['wr_skey'] = get_wr_skey() + errnum += 1 num -= 1 if num == 200: print("阅读脚本运行已完成!") - push("阅读脚本运行已完成!") + QLAPI.notify("微信阅读",f"阅读脚本运行已完成!共阅读{num * 0.5}分钟") break + elif errnum >3: + print("阅读脚本运行未正常完成!") + QLAPI.notify("微信阅读","阅读脚本运行未正常完成!共阅读{num * 0.5}分钟") + + break data.pop('s')