├── .idea ├── inspectionProfiles │ └── Project_Default.xml └── workspace.xml ├── README.md ├── core ├── api.py ├── scan_login.py ├── super_topic_list.py └── topic_check_in.py ├── requirements.txt ├── res ├── check_in.png ├── favicon.ico ├── home.png ├── icon.png ├── login_success.png ├── scan_login.png └── 画了个寂寞.png ├── settings.py ├── src ├── login_ui.py └── main_ui.py ├── start.py └── utils └── requests_strength.py /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 35 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 1609223975997 98 | 139 | 140 | 1624750554849 141 | 146 | 147 | 1648895153014 148 | 153 | 156 | 157 | 159 | 160 | 169 | 171 | 172 | 173 | 174 | 176 | 177 | 178 | 179 | 180 | 181 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🎨WBTopicCheckTool 2 | 3 | ## 前言 4 | 5 | 由于之前的很多接口作废了,暂时也不想花时间在这上面了,之前也挖了点坑,这个写出来算是给之前 [WeiBo_SuperTopics](https://github.com/ReaJason/WeiBo_SuperTopics) 一个交代,简单的用 PyQt5 封装了微博网页版的扫码登陆以及签到请求,想要学习的小伙伴可以下载源码进行学习。 6 | 7 | ## 开发环境 8 | 9 | 1. Windows 10 10 | 2. Python 3.7.9 11 | 3. requests==2.25.1,PyQt5==5.15.1 12 | 13 | ## 界面截图 14 | 15 | ![home](https://cdn.jsdelivr.net/gh/ReaJason/WBTopicCheckTool/res/home.png) 16 | 17 | ![scan_login](https://cdn.jsdelivr.net/gh/ReaJason/WBTopicCheckTool/res/scan_login.png) 18 | 19 | ![login_success](https://cdn.jsdelivr.net/gh/ReaJason/WBTopicCheckTool/res/login_success.png) 20 | 21 | ![check_in.png](https://cdn.jsdelivr.net/gh/ReaJason/WBTopicCheckTool/res/check_in.png) 22 | 23 | ## 注意事项 24 | 25 | 1. 下载源码之后,先安装第三方库`pip install -r requirements.txt `,再使用 `python start.py`启动程序 26 | 2. 程序打包命令,`pyinstaller -F -w -i ./res/favicon.ico start.py`,然后将`res`目录复制到 `dist`目录 27 | 3. 扫码登录成功之后会自动获取超话列表,获取失败,刷新超话重新获取即可 28 | 4. 超话数量越多,签到间隔建议设置大一点,以防请求异常 29 | 5. 若无法使用本程序,请检查自己账号是否异常,不要拿异常账号反馈 30 | 6. 本程序只供参考学习,请勿用于违法用途 31 | 7. 使用本程序导致微博账号异常或冻结甚至封禁都与作者无关 32 | 8. 凡以任何方式下载使用本程序者,视为自愿接受本声明约束。 -------------------------------------------------------------------------------- /core/api.py: -------------------------------------------------------------------------------- 1 | """ 2 | 接口来自于:https://weibo.com/,新版界面 3 | __author__ = "ReaJason" 4 | __date__ = "2021年2月4日" 5 | __site__ = "https://reajason.top" 6 | __email__ = "reajason@163.com" 7 | """ 8 | from utils.requests_strength import pac_requests 9 | 10 | 11 | # 获取用户id 12 | def get_uid(cookie): 13 | res = pac_requests('GET', "https://weibo.com/ajax/side/userType", headers_={"cookie": cookie}) 14 | if res['status']: 15 | return res['response'].headers.get('X-Log-Uid') 16 | return None 17 | 18 | 19 | # 获取用户信息 20 | def get_user_info(uid, cookie): 21 | res = pac_requests('GET', f"https://weibo.com/ajax/profile/info?uid={uid}", headers_={"cookie": cookie}) 22 | if res['status']: 23 | return res['response'].json()['data']['user'] 24 | return None -------------------------------------------------------------------------------- /core/scan_login.py: -------------------------------------------------------------------------------- 1 | """ 2 | 扫码登陆 3 | __author__ = "ReaJason" 4 | __date__ = "2021年2月4日" 5 | __site__ = "https://reajason.top" 6 | __email__ = "reajason@163.com" 7 | """ 8 | import time 9 | import re 10 | 11 | from PyQt5.QtCore import QThread, pyqtSignal 12 | from core.api import get_uid, get_user_info 13 | 14 | 15 | def get_qrcode(session): 16 | headers = { 17 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " 18 | "Chrome/86.0.4240.75 Safari/537.36", 19 | "Referer": "https://weibo.com/" 20 | } 21 | """ 22 | https://login.sina.com.cn/sso/qrcode/image?entry=sinawap&size=180&callback=STK_16411913207265 23 | """ 24 | qrcode_url = "https://login.sina.com.cn/sso/qrcode/image?entry=account&size=256&callback=1" 25 | try: 26 | session.get('https://m.weibo.cn/', headers=headers) 27 | res = session.get(qrcode_url, headers=headers) 28 | return { 29 | 'img_url': re.findall(',"image":"(.*)"', res.text)[0].replace('\/', '/'), 30 | 'qrid': re.findall('"qrid":"(.*?)"', res.text)[0] 31 | } 32 | except: 33 | return {} 34 | 35 | 36 | class QRCodeThread(QThread): 37 | signal = pyqtSignal(dict) 38 | 39 | def __init__(self, session): 40 | super().__init__() 41 | self.session = session 42 | 43 | def run(self): 44 | qr_dict = get_qrcode(self.session) 45 | self.signal.emit(qr_dict) 46 | 47 | 48 | def login(session, alt): 49 | login_url = "https://login.sina.com.cn/sso/login.php" 50 | headers = { 51 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " 52 | "Chrome/86.0.4240.75 Safari/537.36", 53 | "Referer": "https://weibo.com/" 54 | } 55 | login_params = { 56 | "entry": "sinawap", 57 | "returntype": "TEXT", 58 | "crossdomain": "1", 59 | "cdult": "3", 60 | "domain": "weibo.com", 61 | "alt": alt, 62 | "savestate": "30", 63 | "callback": "1", 64 | } 65 | try: 66 | res = session.get(login_url, params=login_params, headers=headers) 67 | print(res.text) 68 | print(re.findall('"(.*?)"', res.text)[-1].replace('\/', '/')) 69 | print(session.cookies) 70 | res1 = session.get(url=re.findall('"(.*?)"', res.text)[-1].replace('\/', '/'), headers=headers) 71 | print(res1.text) 72 | except Exception as e: 73 | return {'status': 0, 'msg': '网络出错/账号异常'} 74 | cookie = '' 75 | count = 0 76 | for k, v in session.cookies.items(): 77 | if k == 'SUB' and count: 78 | cookie += f"{k}={v}; " 79 | if k == 'SUB': 80 | count += 1 81 | uid = get_uid(cookie) 82 | if uid: 83 | user_info = get_user_info(uid, cookie) 84 | return {'status': 1, 'user': user_info, 'web_cookie': cookie, 'msg': "登录成功"} 85 | else: 86 | return {'status': 0, 'msg': '网络出错/账号异常'} 87 | 88 | 89 | class ScanPicThread(QThread): 90 | scan_signal = pyqtSignal(dict) 91 | 92 | def __init__(self, win, session, qrid): 93 | super(ScanPicThread, self).__init__() 94 | self.qrid = qrid 95 | self.win = win 96 | self.session = session 97 | self.headers = { 98 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " 99 | "Chrome/86.0.4240.75 Safari/537.36", 100 | "Referer": "http://my.sina.com.cn/" 101 | } 102 | 103 | def run(self): 104 | while True: 105 | # 扫码窗口关闭,则结束扫码检测 106 | if not self.win.isVisible(): 107 | return 108 | check_url = f"https://login.sina.com.cn/sso/qrcode/check?entry=weibo&qrid={self.qrid}&callback=1" 109 | try: 110 | time.sleep(1) 111 | res = self.session.get(check_url, headers=self.headers) 112 | msg = re.findall(',"msg":"(.*?)"', res.text)[0] 113 | code = re.findall(':(\d{8})', res.text)[0] 114 | if code == '50114002': 115 | pass 116 | # print(msg) 117 | if code == '50114001': 118 | pass 119 | # print(msg) 120 | if code == '20000000': 121 | alt = re.findall('"alt":"(.*?)"', res.text)[0] 122 | login_dict = login(self.session, alt) 123 | self.scan_signal.emit(login_dict) 124 | except Exception as e: 125 | print(e) 126 | print(e.__class__) 127 | -------------------------------------------------------------------------------- /core/super_topic_list.py: -------------------------------------------------------------------------------- 1 | """ 2 | 获取超话列表 3 | __author__ = "ReaJason" 4 | __date__ = "2021年6月27日" 5 | __site__ = "https://reajason.top" 6 | __email__ = "reajason@163.com" 7 | """ 8 | import itertools 9 | import time 10 | 11 | from PyQt5.QtCore import QThread, pyqtSignal 12 | 13 | from utils.requests_strength import pac_requests 14 | 15 | 16 | def get_follow_topic_list_from_internet(cookie): 17 | url = 'https://weibo.com/ajax/profile/topicContent?tabid=231093_-_chaohua&page={}' 18 | super_topic_list = [] 19 | for page_num in itertools.count(1): 20 | time.sleep(1) 21 | res = pac_requests('GET', url.format(page_num), headers_={"cookie": cookie}) 22 | print(res['response'].json()) 23 | if not res['status']: 24 | return [] 25 | lists = res['response'].json()['data']['list'] 26 | if not lists: 27 | return super_topic_list 28 | super_topic_list.extend( 29 | [ 30 | { 31 | 'title': _['title'], 32 | 'id': _['oid'].split(':')[-1], 33 | # 'url': f'https:{_["link"]}', 34 | # 'pic': _['pic'].replace('thumbnail', 'large'), 35 | } for _ in lists 36 | ] 37 | ) 38 | 39 | 40 | class TopicListThread(QThread): 41 | signal = pyqtSignal(list) 42 | 43 | def __int__(self): 44 | super(TopicListThread, self).__int__() 45 | self.cookie = None 46 | self.username = None 47 | 48 | def run(self): 49 | super_topic_list = get_follow_topic_list_from_internet(self.cookie) 50 | self.signal.emit(super_topic_list) 51 | -------------------------------------------------------------------------------- /core/topic_check_in.py: -------------------------------------------------------------------------------- 1 | """ 2 | 超话签到 3 | __author__ = "ReaJason" 4 | __date__ = "2021年2月4日" 5 | __site__ = "https://reajason.top" 6 | __email__ = "reajason@163.com" 7 | """ 8 | import time 9 | 10 | from PyQt5.QtCore import QThread, pyqtSignal 11 | from utils.requests_strength import pac_requests, get_user_agent 12 | 13 | 14 | def super_topic_check_in(cookie, super_topic_dict): 15 | url = 'https://weibo.com/p/aj/general/button' 16 | params = { 17 | "ajwvr": "6", 18 | "api": "http://i.huati.weibo.com/aj/super/checkin", 19 | "texta": "签到", 20 | "textb": "已签到", 21 | "status": "0", 22 | "id": super_topic_dict["id"], 23 | "location": "page_100808_super_index", 24 | "timezone": "GMT 0800", 25 | "lang": "zh-cn", 26 | "plat": "Win32", 27 | "ua": get_user_agent, 28 | "screen": "1536*864", 29 | "__rnd": str(int(round(time.time() * 1000))), 30 | } 31 | res = pac_requests('GET', url, params=params, headers_={'cookie': cookie, 32 | 'referer': f'https://weibo.com/p/{super_topic_dict["id"]}/super_index'}) 33 | print(res) 34 | if not res['status']: 35 | return {'status': 0, 'msg': res['errmsg']} 36 | try: 37 | print(res['response'].text) 38 | res['response'].json() 39 | except: 40 | return {'status': 0, 'msg': "请求异常"} 41 | if res['response'].json()['code'] == '100000': 42 | return { 43 | 'status': 1, 44 | 'msg': f'{res["response"].json()["data"]["alert_title"]},{res["response"].json()["data"]["alert_subtitle"]}' 45 | } 46 | elif res['response'].json()['code'] == 382004: 47 | return {'status': 1, 'msg': '今天已签到'} 48 | elif res['response'].json()['code'] == 382003: 49 | return {'status': 0, 'msg': '请先关注再签到'} 50 | else: 51 | return {'status': 0, 'msg': res['response'].json()['msg']} 52 | 53 | 54 | class CheckIn(QThread): 55 | signal = pyqtSignal(str) 56 | 57 | def __init__(self, sleep_time, topic_list, cookie): 58 | super(CheckIn, self).__init__() 59 | self.sleep_time = sleep_time 60 | self.topic_list = topic_list 61 | self.cookie = cookie 62 | 63 | def run(self): 64 | for index, topic_dict in enumerate(self.topic_list): 65 | time.sleep(self.sleep_time) 66 | result = super_topic_check_in(cookie=self.cookie, super_topic_dict=topic_dict) 67 | self.signal.emit(f"{index + 1}:{topic_dict['title']},{result['msg']}") 68 | self.signal.emit("所有超话签到完毕,如有失败请单签") 69 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests==2.25.1 2 | PyQt5==5.15.1 -------------------------------------------------------------------------------- /res/check_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReaJason/WBTopicCheckTool/fcc778d94bfb843301e2bb52e4ccda56e27294bb/res/check_in.png -------------------------------------------------------------------------------- /res/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReaJason/WBTopicCheckTool/fcc778d94bfb843301e2bb52e4ccda56e27294bb/res/favicon.ico -------------------------------------------------------------------------------- /res/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReaJason/WBTopicCheckTool/fcc778d94bfb843301e2bb52e4ccda56e27294bb/res/home.png -------------------------------------------------------------------------------- /res/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReaJason/WBTopicCheckTool/fcc778d94bfb843301e2bb52e4ccda56e27294bb/res/icon.png -------------------------------------------------------------------------------- /res/login_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReaJason/WBTopicCheckTool/fcc778d94bfb843301e2bb52e4ccda56e27294bb/res/login_success.png -------------------------------------------------------------------------------- /res/scan_login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReaJason/WBTopicCheckTool/fcc778d94bfb843301e2bb52e4ccda56e27294bb/res/scan_login.png -------------------------------------------------------------------------------- /res/画了个寂寞.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReaJason/WBTopicCheckTool/fcc778d94bfb843301e2bb52e4ccda56e27294bb/res/画了个寂寞.png -------------------------------------------------------------------------------- /settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | __all__ = [ 5 | "ICON_PATH", 6 | "ROOT_PATH" 7 | ] 8 | 9 | ROOT_PATH = os.path.dirname(os.path.realpath(sys.argv[0])) 10 | RES_PATH = os.path.join(ROOT_PATH, 'res') 11 | ICON_PATH = os.path.join(RES_PATH, "icon.png") -------------------------------------------------------------------------------- /src/login_ui.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtGui import QImage, QIcon, QPixmap 2 | from PyQt5.QtCore import pyqtSignal 3 | from PyQt5.QtWidgets import QDialog, QLabel, QHBoxLayout 4 | from settings import ICON_PATH 5 | from core.scan_login import ScanPicThread 6 | 7 | __author__ = "ReaJason" 8 | __date__ = "2021年2月4日" 9 | __site__ = "https://reajason.top" 10 | __email__ = "reajason@163.com" 11 | 12 | 13 | class ScanImage(QDialog): 14 | signal = pyqtSignal(dict) 15 | 16 | def __init__(self, session, qr_dict): 17 | super().__init__() 18 | self.qrid = qr_dict['qrid'] 19 | self.setWindowTitle('扫码登录') 20 | self.setWindowIcon(QIcon(ICON_PATH)) 21 | layout = QHBoxLayout() 22 | self.pic_lb = QLabel() 23 | res = session.get(qr_dict['img_url']).content 24 | img = QImage.fromData(res) 25 | self.pic_lb.setPixmap(QPixmap.fromImage(img)) 26 | layout.addWidget(self.pic_lb) 27 | self.setLayout(layout) 28 | self.scan_check_t = ScanPicThread(self, session, self.qrid) 29 | self.scan_check_t.start() 30 | self.scan_check_t.scan_signal.connect(self.emit_signal) 31 | 32 | def emit_signal(self, login_dict): 33 | self.signal.emit(login_dict) 34 | self.close() 35 | -------------------------------------------------------------------------------- /src/main_ui.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import ctypes 3 | import requests 4 | 5 | from PyQt5.QtGui import QIcon, QDesktopServices, QFont 6 | from PyQt5.QtCore import QEvent, QUrl, Qt 7 | from PyQt5.QtWidgets import QDialog, QLabel, QGridLayout, QPushButton, QComboBox, QMessageBox, QListWidget, QSpinBox, \ 8 | QApplication, QStyleFactory, QWhatsThis 9 | 10 | from core.super_topic_list import TopicListThread 11 | from core.scan_login import QRCodeThread 12 | from core.topic_check_in import CheckIn, super_topic_check_in 13 | from src.login_ui import ScanImage 14 | from settings import ICON_PATH 15 | 16 | __author__ = "ReaJason" 17 | __date__ = "2021年6月27日" 18 | __site__ = "https://reajason.top" 19 | __email__ = "reajason@163.com" 20 | 21 | 22 | class MainWin(QDialog): 23 | def __init__(self): 24 | super(MainWin, self).__init__() 25 | self.setWindowTitle('微博超话工具 v2.1(By ReaJason)') 26 | 27 | # self.setFixedSize(500, 300) 28 | 29 | self.setWindowIcon(QIcon(ICON_PATH)) 30 | 31 | font = QFont() 32 | font.setFamily('微软雅黑') 33 | self.setFont(font) 34 | 35 | self.cookie = None 36 | self.username = None 37 | self.super_topic_list = [] 38 | 39 | layout = QGridLayout() 40 | 41 | lb1 = QLabel("昵称:") 42 | self.nick_lb = QLabel("等待登录...") 43 | 44 | lb2 = QLabel("签到间隔:") 45 | self.check_sleep = QSpinBox() 46 | self.check_sleep.setMinimum(1) 47 | 48 | self.super_topic_combo = QComboBox() 49 | self.super_topic_combo.addItem("超话列表") 50 | 51 | self.refresh_btn = QPushButton("刷新超话") 52 | self.refresh_btn.clicked.connect(self.refresh_topic_list) 53 | 54 | self.login_btn = QPushButton("扫码登录") 55 | self.login_btn.clicked.connect(self.scan_qr) 56 | 57 | self.check_all_btn = QPushButton("一键全签") 58 | self.check_all_btn.clicked.connect(self.check_in_all) 59 | 60 | self.check_one_btn = QPushButton("单签所选") 61 | self.check_one_btn.clicked.connect(self.check_in_one) 62 | 63 | self.log_widget = QListWidget() 64 | 65 | layout.addWidget(self.login_btn, 0, 2) 66 | layout.addWidget(lb1, 0, 0, Qt.AlignRight) 67 | layout.addWidget(self.nick_lb, 0, 1) 68 | layout.addWidget(lb2, 1, 0, Qt.AlignRight) 69 | layout.addWidget(self.check_sleep, 1, 1) 70 | layout.addWidget(self.super_topic_combo, 2, 0) 71 | layout.addWidget(self.refresh_btn, 2, 1) 72 | layout.addWidget(self.check_all_btn, 1, 2) 73 | layout.addWidget(self.check_one_btn, 2, 2) 74 | layout.addWidget(self.log_widget, 4, 0, 1, 3) 75 | self.setLayout(layout) 76 | 77 | def scan_qr(self): 78 | """ 79 | 开启线程,获取二维码信息 80 | :return: 81 | """ 82 | self.session = requests.session() 83 | self.q_t = QRCodeThread(self.session) 84 | self.q_t.start() 85 | self.q_t.signal.connect(self.scan_login) 86 | 87 | def scan_login(self, qr_dict): 88 | """ 89 | 通过二维码,开启扫码窗口 90 | :param qr_dict: 91 | :return: 92 | """ 93 | if not qr_dict: 94 | QMessageBox.warning(self, "警告", "获取二维码失败") 95 | return 96 | # 打开二维码 97 | self.log_widget.addItem("获取二维码成功!") 98 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 99 | self.scan_win = ScanImage(self.session, qr_dict) 100 | self.scan_win.show() 101 | self.scan_win.signal.connect(self._del_scan_login) 102 | 103 | def _del_scan_login(self, login_dict): 104 | """ 105 | 获取登录信息,处理登录结果 106 | :param login_dict: 107 | :return: 108 | """ 109 | print(login_dict) 110 | if login_dict['status']: 111 | self.cookie = login_dict['web_cookie'] 112 | print(self.cookie) 113 | self.username = login_dict['user']['screen_name'] 114 | self.nick_lb.setText(self.username) 115 | self.log_widget.addItem(f"{login_dict['user']['screen_name']},{login_dict['msg']}") 116 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 117 | self.refresh_topic_list() 118 | else: 119 | self.log_widget.addItem(login_dict) 120 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 121 | 122 | def refresh_topic_list(self): 123 | if not self.cookie: 124 | QMessageBox.warning(self, "警告", "未检测到登录状态") 125 | return 126 | self.refresh_t = TopicListThread() 127 | self.refresh_t.cookie = self.cookie 128 | self.refresh_t.username = self.username 129 | self.refresh_t.start() 130 | self.refresh_t.signal.connect(self._del_refresh_topic_list) 131 | self.log_widget.addItem("正在获取超话列表。。。") 132 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 133 | 134 | def _del_refresh_topic_list(self, super_topic_list): 135 | if super_topic_list: 136 | self.super_topic_list = super_topic_list 137 | self.super_topic_combo.clear() 138 | for super_topic_dict in super_topic_list: 139 | print(super_topic_dict) 140 | self.super_topic_combo.addItem(super_topic_dict['title']) 141 | self.log_widget.addItem(f"获取超话列表成功,一共获取到超话数:{len(super_topic_list)}个") 142 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 143 | else: 144 | self.log_widget.addItem("获取超话列表失败") 145 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 146 | 147 | def check_in_all(self): 148 | if not self.cookie: 149 | QMessageBox.warning(self, "警告", "未检测到登录状态") 150 | return 151 | self.check_in_t = CheckIn( 152 | cookie=self.cookie, sleep_time=self.check_sleep.value(), topic_list=self.super_topic_list) 153 | self.check_in_t.start() 154 | self.check_in_t.signal.connect(self.push_msg) 155 | 156 | def check_in_one(self): 157 | if not self.cookie: 158 | QMessageBox.warning(self, "警告", "未检测到登录状态") 159 | return 160 | topic_name = self.super_topic_combo.currentText() 161 | super_topic = [i for i in self.super_topic_list if i['title'] == topic_name][0] 162 | result = super_topic_check_in(self.cookie, super_topic) 163 | self.log_widget.addItem(f"{topic_name},{result['msg']}") 164 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 165 | 166 | def push_msg(self, msg): 167 | self.log_widget.addItem(msg) 168 | self.log_widget.setCurrentRow(self.log_widget.count() - 1) 169 | 170 | # 监听Dialog窗口右上角帮助按钮 171 | def event(self, event): 172 | if event.type() == QEvent.EnterWhatsThisMode: 173 | QWhatsThis.leaveWhatsThisMode() 174 | QDesktopServices.openUrl(QUrl("https://github.com/ReaJason")) 175 | return QDialog.event(self, event) 176 | 177 | # 窗口关闭按钮事件 178 | def closeEvent(self, event): 179 | reply = QMessageBox.question(self, '提醒', '确定要退出吗?', QMessageBox.Yes, QMessageBox.No) 180 | if reply == QMessageBox.Yes: 181 | event.accept() 182 | else: 183 | event.ignore() 184 | 185 | 186 | def run(): 187 | ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid") 188 | 189 | QApplication.setStyle(QStyleFactory.create('Fusion')) 190 | 191 | app = QApplication(sys.argv) 192 | win = MainWin() 193 | win.show() 194 | sys.exit(app.exec_()) 195 | -------------------------------------------------------------------------------- /start.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from src.main_ui import run 4 | 5 | __author__ = "ReaJason" 6 | __date__ = "2021年2月4日" 7 | __site__ = "https://reajason.top" 8 | __email__ = "reajason@163.com" 9 | 10 | sys.path.append(os.path.dirname(__file__)) 11 | 12 | 13 | if __name__ == '__main__': 14 | run() 15 | -------------------------------------------------------------------------------- /utils/requests_strength.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import random 3 | 4 | 5 | def get_user_agent(): 6 | windows_user_agent = [ 7 | 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 ' 8 | 'Safari/537.36', 9 | 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 ' 10 | 'Safari/537.36 Edg/86.0.622.68', 11 | 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0' 12 | ] 13 | return random.choice(windows_user_agent) 14 | 15 | 16 | def pac_requests(method, url, timeout=30, headers_=None, **kwargs): 17 | headers = { 18 | 'user-agent': get_user_agent() 19 | } 20 | if headers_: 21 | headers.update(headers_) 22 | try: 23 | res = requests.request( 24 | method=method, 25 | url=url, 26 | timeout=timeout, headers=headers, **kwargs) 27 | if res.status_code == 200: 28 | return {'status': 1, 'response': res} 29 | else: 30 | print(f'访问出错,{res.status_code}') 31 | print(res.text) 32 | return {'status': 0, 'errmsg': f'访问出错,{res.status_code}'} 33 | except requests.exceptions.ConnectionError: 34 | print('无法访问网络,获取失败') 35 | return {'status': 0, 'errmsg': '无法访问网络,获取失败'} 36 | except requests.exceptions.ConnectTimeout: 37 | print('网络连接超时,获取失败') 38 | return {'status': 0, 'errmsg': '网络连接超时,获取失败'} 39 | except Exception as e: 40 | print(f'错误类型:{e}\n错误详情:{e.__class__}') 41 | return {'status': 0, 'errmsg': f'错误类型:{e}\n错误详情:{e.__class__}'} --------------------------------------------------------------------------------