feat: gui界面
This commit is contained in:
parent
54019e9e5d
commit
c408437712
Binary file not shown.
After Width: | Height: | Size: 953 KiB |
|
@ -0,0 +1,489 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>725</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>725</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>725</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>总院网络巡查系统</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>start.ico</normaloff>start.ico</iconset>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>601</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>banner.jpg</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>280</y>
|
||||
<width>191</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>1.微信公众号信息抓取</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="bWechat">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>75</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开工具</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>161</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>请确保所有公众号抓取完毕</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>380</y>
|
||||
<width>191</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>2.确认需要抓取的网站</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="bWebSite">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>151</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开网站列表Excel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>151</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>请在修改后保存并关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>500</y>
|
||||
<width>191</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>2.确认分析对比库</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="bBiao">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>151</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开分析标准Excel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>151</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>请在修改后保存并关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>280</y>
|
||||
<width>381</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>4.开始执行巡查</string>
|
||||
</property>
|
||||
<widget class="QListView" name="vLog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>80</y>
|
||||
<width>361</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="bStart">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>50</y>
|
||||
<width>75</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>开始巡查</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>251</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>务必确认前3步已经完成;如日志框中出现错误,请联系开发者曹工-18911936305</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lSize">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>20</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>30</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>20</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>KB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>610</y>
|
||||
<width>581</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>最终结果</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>分析结果Excel:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>分析报告Word:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>561</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lRes1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>15</y>
|
||||
<width>381</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lRes2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>40</y>
|
||||
<width>381</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="bRes1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>520</x>
|
||||
<y>10</y>
|
||||
<width>51</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="bRes2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>520</x>
|
||||
<y>40</y>
|
||||
<width>51</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<y>0</y>
|
||||
<width>171</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:white;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>总院网络巡查系统</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -4,3 +4,5 @@ pandas==2.0.0
|
|||
openpyxl==3.1.2
|
||||
scrapy-xlsx==0.1.1
|
||||
selenium==4.9.1
|
||||
pyside6==6.5.2
|
||||
pywin32==306
|
|
@ -0,0 +1,229 @@
|
|||
import sys
|
||||
from PySide6.QtCore import QStringListModel, QThread, Signal
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow
|
||||
from PySide6.QtGui import QIntValidator
|
||||
from ui_mainwindow import Ui_MainWindow
|
||||
import win32com.client as win32
|
||||
import subprocess
|
||||
import os
|
||||
import datetime
|
||||
from mycode.main import make_simple_csv_from_db, make_wechat_articles_full, ana_web, ana_wechat, output_dir
|
||||
from mycode.crawl_chrome import chrom_main_from_list
|
||||
import pandas as pd
|
||||
from urllib.parse import urlparse
|
||||
from openpyxl import load_workbook
|
||||
import threading
|
||||
import select
|
||||
# from queue import Queue
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
WEB_SITES_PATH = os.path.join(BASE_DIR, 'web_sites.xlsx')
|
||||
BIAO_PATH = os.path.join(BASE_DIR, 'biao.xlsx')
|
||||
PYTHON_PATH = os.path.join(BASE_DIR, 'runtime/python.exe')
|
||||
TEMPLATE_PATH = os.path.join(BASE_DIR, 'summary/template.xlsx')
|
||||
|
||||
class MyApplication(QApplication):
|
||||
def __init__(self, argv):
|
||||
super(MyApplication, self).__init__(argv)
|
||||
self.main_window = None
|
||||
|
||||
def createMainWindow(self):
|
||||
if self.main_window is None:
|
||||
self.main_window = MainWindow()
|
||||
return self.main_window
|
||||
|
||||
class MyThread(QThread):
|
||||
update_signal = Signal(dict)
|
||||
|
||||
def __init__(self, lsize) -> None:
|
||||
super().__init__()
|
||||
self.lsize = lsize
|
||||
self.processes = []
|
||||
self.running = False
|
||||
|
||||
def capture_output(self, p):
|
||||
while self.running and p.poll() is None:
|
||||
output = p.stdout.readline()
|
||||
if output:
|
||||
self.update_signal.emit({'msg': output.strip()})
|
||||
|
||||
def run(self) -> None:
|
||||
month = datetime.datetime.now().month
|
||||
self.update_signal.emit({'msg': '巡查任务开始...'})
|
||||
self.update_signal.emit({'msg': '正在组合微信公众号爬取内容...'})
|
||||
make_simple_csv_from_db()
|
||||
make_wechat_articles_full()
|
||||
self.update_signal.emit({'msg': "公众号爬取内容组装完毕!"})
|
||||
self.update_signal.emit({'msg': '开始进行网站爬取...'})
|
||||
df = pd.read_excel('web_sites.xlsx', sheet_name='Sheet1')
|
||||
ind = 0
|
||||
for ind, row in df.iterrows():
|
||||
group = row['单位']
|
||||
name = row['主办']
|
||||
url = row['地址']
|
||||
domain = urlparse(url).netloc.replace('www.', '')
|
||||
# output = os.path.join(BASE_DIR, f'web_dir/{name}_{domain}.xlsx')
|
||||
# -u 代表不缓冲,直接输出
|
||||
cmd = [PYTHON_PATH, '-u', '-m', 'scrapy', 'crawl', 'basespider', '-a', f'domain={domain}', '-a', f'start_url={url}', '-a', f'name={name}', '-a', f'group={group}', '-o', f'web_dir/{name}_{domain}.xlsx']
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=False)
|
||||
self.processes.append(process)
|
||||
self.running = True
|
||||
getlog_thread = threading.Thread(target=self.capture_output, args=(process,), daemon=True)
|
||||
getlog_thread.start()
|
||||
|
||||
for process in self.processes:
|
||||
process.wait()
|
||||
self.update_signal.emit({'msg': '网站爬取结束,校验中...'})
|
||||
info_to_save = []
|
||||
for ind, row in df.iterrows():
|
||||
group = row['单位']
|
||||
name = row['主办']
|
||||
url = row['地址']
|
||||
domain = urlparse(url).netloc.replace("www.", "")
|
||||
output_filename = os.path.join(BASE_DIR, f'web_dir/{name}_{domain}.xlsx')
|
||||
if os.path.exists(output_filename):
|
||||
file_size = os.path.getsize(output_filename)
|
||||
if file_size < self.lsize * 1024: # Convert KB to bytes
|
||||
info_to_save.append([group, name, url])
|
||||
if info_to_save:
|
||||
self.update_signal.emit({'msg': '存在未爬取站点,正在调用Chrome继续爬取...'})
|
||||
chrom_main_from_list(info_to_save)
|
||||
self.update_signal.emit({'msg': '网站爬取完毕!'})
|
||||
self.update_signal.emit({'msg': '开始对比分析所有内容...'})
|
||||
wechat_results = ana_wechat()
|
||||
web_results = ana_web()
|
||||
output_excel_path = os.path.join(BASE_DIR, f'summary/{month}月-总院及下属公司官方公众号巡查结果汇总表.xlsx')
|
||||
workbook = load_workbook(TEMPLATE_PATH)
|
||||
# 选择要操作的工作表
|
||||
wechat_sheet = workbook['公众号']
|
||||
web_sheet = workbook['网站']
|
||||
for row in wechat_results:
|
||||
wechat_sheet.append(row)
|
||||
for row in web_results:
|
||||
web_sheet.append(row)
|
||||
workbook.save(output_excel_path)
|
||||
workbook.close()
|
||||
self.update_signal.emit({'msg': '巡查任务执行完毕, 请查看结果栏, 可手动校对', 'output_excel_path': output_excel_path})
|
||||
self.exec()
|
||||
|
||||
def close(self):
|
||||
self.running = False
|
||||
if self.processes:
|
||||
for i in self.processes:
|
||||
i.kill()
|
||||
self.terminate()
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
super(MainWindow, self).__init__()
|
||||
self.worker_thread = None
|
||||
self.wcplus = False
|
||||
self.logModel= QStringListModel([])
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
self.ui.lSize.setValidator(QIntValidator())
|
||||
self.ui.bWechat.clicked.connect(self.open_wcplus)
|
||||
self.ui.bWebSite.clicked.connect(self.open_websites_xlsx)
|
||||
self.ui.bBiao.clicked.connect(self.open_biao_xlsx)
|
||||
self.ui.bStart.clicked.connect(self.start)
|
||||
self.ui.bRes1.clicked.connect(self.open_res1)
|
||||
self.ui.bRes2.clicked.connect(self.open_res2)
|
||||
self.ui.vLog.setModel(self.logModel)
|
||||
self.res1Workbook = None
|
||||
|
||||
def open_wcplus(self):
|
||||
if self.wcplus is False:
|
||||
subprocess.Popen('.\wechat.exe')
|
||||
self.wcplus = True
|
||||
|
||||
def open_websites_xlsx(self):
|
||||
app = win32.Dispatch("Excel.Application")
|
||||
app.Visible = True
|
||||
app.Workbooks.Open(WEB_SITES_PATH)
|
||||
app.WindowState = 3
|
||||
|
||||
def open_biao_xlsx(self):
|
||||
app = win32.Dispatch("Excel.Application")
|
||||
app.Visible = True
|
||||
app.Workbooks.Open(BIAO_PATH)
|
||||
app.WindowState = 3
|
||||
|
||||
def open_res1(self):
|
||||
if self.ui.lRes1.text():
|
||||
app = win32.Dispatch("Excel.Application")
|
||||
app.Visible = True
|
||||
self.res1Workbook = app.Workbooks.Open(self.ui.lRes1.text())
|
||||
app.WindowState = 3
|
||||
|
||||
def open_res2(self):
|
||||
if self.ui.lRes2.text():
|
||||
app = win32.Dispatch("Excel.Application")
|
||||
app.Visible = True
|
||||
app.Workbooks.Open(self.ui.lRes2.text())
|
||||
app.WindowState = 3
|
||||
|
||||
def get_time(self):
|
||||
now = datetime.datetime.now()
|
||||
return now.strftime('%H:%M:%S')
|
||||
|
||||
def start(self):
|
||||
if self.ui.bStart.text() == '开始巡查' or self.ui.bStart.text() == '重新开始':
|
||||
self.log('', True)
|
||||
if self.res1Workbook:
|
||||
self.res1Workbook.Close()
|
||||
self.ui.lSize.setEnabled(False)
|
||||
self.ui.bStart.setText('停止巡查')
|
||||
self.start_web(int(self.ui.lSize.text()))
|
||||
elif self.ui.bStart.text() == '停止巡查':
|
||||
self.update_log({'msg': '正在停止...'})
|
||||
if self.worker_thread:
|
||||
self.worker_thread.close()
|
||||
self.log('', True)
|
||||
self.ui.lSize.setEnabled(True)
|
||||
self.ui.bStart.setText('开始巡查')
|
||||
|
||||
|
||||
def start_web(self, lsize):
|
||||
self.worker_thread = MyThread(lsize)
|
||||
self.worker_thread.update_signal.connect(self.update_log)
|
||||
self.worker_thread.start()
|
||||
|
||||
def update_log(self, rdict):
|
||||
self.log(f'{self.get_time()}-{rdict["msg"]}', False)
|
||||
if 'output_excel_path' in rdict:
|
||||
self.ui.lRes1.setText(rdict['output_excel_path'])
|
||||
self.ui.bStart.setText('重新开始')
|
||||
self.ui.lSize.setEnabled(True)
|
||||
|
||||
def log(self, logLine: str, clear=False):
|
||||
log_list = self.logModel.stringList()
|
||||
if clear:
|
||||
log_list = []
|
||||
else:
|
||||
log_list.append(logLine)
|
||||
self.logModel.setStringList(log_list)
|
||||
if clear:
|
||||
self.ui.vLog.scrollToTop()
|
||||
else:
|
||||
self.ui.vLog.scrollToBottom()
|
||||
|
||||
def closeEvent(self, event):
|
||||
if self.wcplus:
|
||||
try:
|
||||
subprocess.Popen(['taskkill', '/F', '/IM', 'wechat.exe'])
|
||||
except Exception as e:
|
||||
print(f"Error while terminating WeChat.exe: {str(e)}")
|
||||
self.wcplus = False
|
||||
if self.worker_thread:
|
||||
self.worker_thread.close()
|
||||
event.accept()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = MyApplication(sys.argv)
|
||||
main_window = app.createMainWindow()
|
||||
main_window.show()
|
||||
|
||||
sys.exit(app.exec())
|
|
@ -0,0 +1,193 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'main.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.5.2
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QFrame, QGroupBox, QLabel,
|
||||
QLineEdit, QListView, QMainWindow, QMenuBar,
|
||||
QPushButton, QSizePolicy, QStatusBar, QWidget)
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
if not MainWindow.objectName():
|
||||
MainWindow.setObjectName(u"MainWindow")
|
||||
MainWindow.resize(600, 725)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
|
||||
MainWindow.setSizePolicy(sizePolicy)
|
||||
MainWindow.setMinimumSize(QSize(600, 725))
|
||||
MainWindow.setMaximumSize(QSize(600, 725))
|
||||
icon = QIcon()
|
||||
icon.addFile(u"start.ico", QSize(), QIcon.Normal, QIcon.Off)
|
||||
MainWindow.setWindowIcon(icon)
|
||||
MainWindow.setAutoFillBackground(False)
|
||||
self.centralwidget = QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName(u"centralwidget")
|
||||
self.label = QLabel(self.centralwidget)
|
||||
self.label.setObjectName(u"label")
|
||||
self.label.setGeometry(QRect(0, 0, 601, 271))
|
||||
self.label.setPixmap(QPixmap(u"banner.jpg"))
|
||||
self.label.setScaledContents(True)
|
||||
self.groupBox = QGroupBox(self.centralwidget)
|
||||
self.groupBox.setObjectName(u"groupBox")
|
||||
self.groupBox.setGeometry(QRect(10, 280, 191, 91))
|
||||
font = QFont()
|
||||
font.setPointSize(11)
|
||||
self.groupBox.setFont(font)
|
||||
self.bWechat = QPushButton(self.groupBox)
|
||||
self.bWechat.setObjectName(u"bWechat")
|
||||
self.bWechat.setGeometry(QRect(20, 30, 75, 24))
|
||||
self.label_5 = QLabel(self.groupBox)
|
||||
self.label_5.setObjectName(u"label_5")
|
||||
self.label_5.setGeometry(QRect(20, 60, 161, 16))
|
||||
font1 = QFont()
|
||||
font1.setPointSize(10)
|
||||
self.label_5.setFont(font1)
|
||||
self.label_5.setStyleSheet(u"color: red;")
|
||||
self.groupBox_2 = QGroupBox(self.centralwidget)
|
||||
self.groupBox_2.setObjectName(u"groupBox_2")
|
||||
self.groupBox_2.setGeometry(QRect(10, 380, 191, 111))
|
||||
self.groupBox_2.setFont(font)
|
||||
self.bWebSite = QPushButton(self.groupBox_2)
|
||||
self.bWebSite.setObjectName(u"bWebSite")
|
||||
self.bWebSite.setGeometry(QRect(20, 30, 151, 24))
|
||||
self.label_2 = QLabel(self.groupBox_2)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
self.label_2.setGeometry(QRect(20, 70, 151, 16))
|
||||
self.label_2.setFont(font1)
|
||||
self.label_2.setStyleSheet(u"color: red;")
|
||||
self.groupBox_3 = QGroupBox(self.centralwidget)
|
||||
self.groupBox_3.setObjectName(u"groupBox_3")
|
||||
self.groupBox_3.setGeometry(QRect(10, 500, 191, 101))
|
||||
self.groupBox_3.setFont(font)
|
||||
self.bBiao = QPushButton(self.groupBox_3)
|
||||
self.bBiao.setObjectName(u"bBiao")
|
||||
self.bBiao.setGeometry(QRect(20, 30, 151, 24))
|
||||
self.label_4 = QLabel(self.groupBox_3)
|
||||
self.label_4.setObjectName(u"label_4")
|
||||
self.label_4.setGeometry(QRect(20, 70, 151, 16))
|
||||
self.label_4.setFont(font1)
|
||||
self.label_4.setStyleSheet(u"color: red;")
|
||||
self.groupBox_4 = QGroupBox(self.centralwidget)
|
||||
self.groupBox_4.setObjectName(u"groupBox_4")
|
||||
self.groupBox_4.setGeometry(QRect(210, 280, 381, 321))
|
||||
self.groupBox_4.setFont(font)
|
||||
self.vLog = QListView(self.groupBox_4)
|
||||
self.vLog.setObjectName(u"vLog")
|
||||
self.vLog.setGeometry(QRect(10, 80, 361, 231))
|
||||
font2 = QFont()
|
||||
font2.setPointSize(9)
|
||||
self.vLog.setFont(font2)
|
||||
self.vLog.setStyleSheet(u"")
|
||||
self.bStart = QPushButton(self.groupBox_4)
|
||||
self.bStart.setObjectName(u"bStart")
|
||||
self.bStart.setGeometry(QRect(300, 50, 75, 24))
|
||||
self.label_6 = QLabel(self.groupBox_4)
|
||||
self.label_6.setObjectName(u"label_6")
|
||||
self.label_6.setGeometry(QRect(10, 30, 251, 41))
|
||||
self.label_6.setFont(font1)
|
||||
self.label_6.setStyleSheet(u"color: red;")
|
||||
self.label_6.setWordWrap(True)
|
||||
self.lSize = QLineEdit(self.groupBox_4)
|
||||
self.lSize.setObjectName(u"lSize")
|
||||
self.lSize.setGeometry(QRect(300, 20, 41, 20))
|
||||
self.label_3 = QLabel(self.groupBox_4)
|
||||
self.label_3.setObjectName(u"label_3")
|
||||
self.label_3.setGeometry(QRect(350, 20, 41, 21))
|
||||
self.groupBox_5 = QGroupBox(self.centralwidget)
|
||||
self.groupBox_5.setObjectName(u"groupBox_5")
|
||||
self.groupBox_5.setGeometry(QRect(10, 610, 581, 71))
|
||||
self.groupBox_5.setFont(font)
|
||||
self.label_7 = QLabel(self.groupBox_5)
|
||||
self.label_7.setObjectName(u"label_7")
|
||||
self.label_7.setGeometry(QRect(10, 20, 91, 16))
|
||||
self.label_7.setFont(font1)
|
||||
self.label_8 = QLabel(self.groupBox_5)
|
||||
self.label_8.setObjectName(u"label_8")
|
||||
self.label_8.setGeometry(QRect(10, 40, 91, 16))
|
||||
self.label_8.setFont(font1)
|
||||
self.line = QFrame(self.groupBox_5)
|
||||
self.line.setObjectName(u"line")
|
||||
self.line.setGeometry(QRect(10, 30, 561, 16))
|
||||
self.line.setFrameShape(QFrame.HLine)
|
||||
self.line.setFrameShadow(QFrame.Sunken)
|
||||
self.lRes1 = QLabel(self.groupBox_5)
|
||||
self.lRes1.setObjectName(u"lRes1")
|
||||
self.lRes1.setGeometry(QRect(110, 15, 381, 21))
|
||||
self.lRes1.setFont(font2)
|
||||
self.lRes2 = QLabel(self.groupBox_5)
|
||||
self.lRes2.setObjectName(u"lRes2")
|
||||
self.lRes2.setGeometry(QRect(110, 40, 381, 16))
|
||||
self.lRes2.setFont(font2)
|
||||
self.bRes1 = QPushButton(self.groupBox_5)
|
||||
self.bRes1.setObjectName(u"bRes1")
|
||||
self.bRes1.setGeometry(QRect(520, 10, 51, 24))
|
||||
self.bRes2 = QPushButton(self.groupBox_5)
|
||||
self.bRes2.setObjectName(u"bRes2")
|
||||
self.bRes2.setGeometry(QRect(520, 40, 51, 24))
|
||||
self.label_9 = QLabel(self.centralwidget)
|
||||
self.label_9.setObjectName(u"label_9")
|
||||
self.label_9.setGeometry(QRect(430, 0, 171, 41))
|
||||
font3 = QFont()
|
||||
font3.setPointSize(14)
|
||||
font3.setBold(True)
|
||||
font3.setItalic(False)
|
||||
self.label_9.setFont(font3)
|
||||
self.label_9.setStyleSheet(u"color:white;")
|
||||
self.label_9.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
|
||||
self.label_9.setMargin(6)
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QMenuBar(MainWindow)
|
||||
self.menubar.setObjectName(u"menubar")
|
||||
self.menubar.setGeometry(QRect(0, 0, 600, 22))
|
||||
MainWindow.setMenuBar(self.menubar)
|
||||
self.statusbar = QStatusBar(MainWindow)
|
||||
self.statusbar.setObjectName(u"statusbar")
|
||||
MainWindow.setStatusBar(self.statusbar)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
|
||||
QMetaObject.connectSlotsByName(MainWindow)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"\u603b\u9662\u7f51\u7edc\u5de1\u67e5\u7cfb\u7edf", None))
|
||||
self.label.setText("")
|
||||
self.groupBox.setTitle(QCoreApplication.translate("MainWindow", u"1.\u5fae\u4fe1\u516c\u4f17\u53f7\u4fe1\u606f\u6293\u53d6", None))
|
||||
self.bWechat.setText(QCoreApplication.translate("MainWindow", u"\u6253\u5f00\u5de5\u5177", None))
|
||||
self.label_5.setText(QCoreApplication.translate("MainWindow", u"\u8bf7\u786e\u4fdd\u6240\u6709\u516c\u4f17\u53f7\u6293\u53d6\u5b8c\u6bd5", None))
|
||||
self.groupBox_2.setTitle(QCoreApplication.translate("MainWindow", u"2.\u786e\u8ba4\u9700\u8981\u6293\u53d6\u7684\u7f51\u7ad9", None))
|
||||
self.bWebSite.setText(QCoreApplication.translate("MainWindow", u"\u6253\u5f00\u7f51\u7ad9\u5217\u8868Excel", None))
|
||||
self.label_2.setText(QCoreApplication.translate("MainWindow", u"\u8bf7\u5728\u4fee\u6539\u540e\u4fdd\u5b58\u5e76\u5173\u95ed", None))
|
||||
self.groupBox_3.setTitle(QCoreApplication.translate("MainWindow", u"2.\u786e\u8ba4\u5206\u6790\u5bf9\u6bd4\u5e93", None))
|
||||
self.bBiao.setText(QCoreApplication.translate("MainWindow", u"\u6253\u5f00\u5206\u6790\u6807\u51c6Excel", None))
|
||||
self.label_4.setText(QCoreApplication.translate("MainWindow", u"\u8bf7\u5728\u4fee\u6539\u540e\u4fdd\u5b58\u5e76\u5173\u95ed", None))
|
||||
self.groupBox_4.setTitle(QCoreApplication.translate("MainWindow", u"4.\u5f00\u59cb\u6267\u884c\u5de1\u67e5", None))
|
||||
self.bStart.setText(QCoreApplication.translate("MainWindow", u"\u5f00\u59cb\u5de1\u67e5", None))
|
||||
self.label_6.setText(QCoreApplication.translate("MainWindow", u"\u52a1\u5fc5\u786e\u8ba4\u524d3\u6b65\u5df2\u7ecf\u5b8c\u6210;\u5982\u65e5\u5fd7\u6846\u4e2d\u51fa\u73b0\u9519\u8bef,\u8bf7\u8054\u7cfb\u5f00\u53d1\u8005\u66f9\u5de5-18911936305", None))
|
||||
self.lSize.setText(QCoreApplication.translate("MainWindow", u"30", None))
|
||||
self.label_3.setText(QCoreApplication.translate("MainWindow", u"KB", None))
|
||||
self.groupBox_5.setTitle(QCoreApplication.translate("MainWindow", u"\u6700\u7ec8\u7ed3\u679c", None))
|
||||
self.label_7.setText(QCoreApplication.translate("MainWindow", u"\u5206\u6790\u7ed3\u679cExcel:", None))
|
||||
self.label_8.setText(QCoreApplication.translate("MainWindow", u"\u5206\u6790\u62a5\u544aWord:", None))
|
||||
self.lRes1.setText("")
|
||||
self.lRes2.setText("")
|
||||
self.bRes1.setText(QCoreApplication.translate("MainWindow", u"\u6253\u5f00", None))
|
||||
self.bRes2.setText(QCoreApplication.translate("MainWindow", u"\u6253\u5f00", None))
|
||||
self.label_9.setText(QCoreApplication.translate("MainWindow", u"\u603b\u9662\u7f51\u7edc\u5de1\u67e5\u7cfb\u7edf", None))
|
||||
# retranslateUi
|
||||
|
2
web3.py
2
web3.py
|
@ -71,7 +71,7 @@ if __name__ == '__main__':
|
|||
output_filename = os.path.join(BASE_DIR, f'web_dir/{name}_{domain}.xlsx')
|
||||
if os.path.exists(output_filename):
|
||||
file_size = os.path.getsize(output_filename)
|
||||
if file_size < 20 * 1024: # Convert KB to bytes
|
||||
if file_size < 30 * 1024: # Convert KB to bytes
|
||||
info_to_save.append([group, name, url])
|
||||
|
||||
if info_to_save:
|
||||
|
|
19
执行巡查.bat
19
执行巡查.bat
|
@ -1,19 +0,0 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
REM 设置 Python 可执行文件路径
|
||||
set PYTHON_EXECUTABLE=.\runtime\python.exe
|
||||
|
||||
REM 设置要运行的 Python 脚本
|
||||
set PYTHON_SCRIPT=web3.py
|
||||
|
||||
REM 运行 Python 脚本
|
||||
%PYTHON_EXECUTABLE% %PYTHON_SCRIPT%
|
||||
|
||||
REM 检查是否有报错
|
||||
if errorlevel 1 (
|
||||
echo 发生错误, 可联系开发人员.
|
||||
pause > nul
|
||||
)
|
||||
|
||||
endlocal
|
|
@ -0,0 +1,44 @@
|
|||
::[Bat To Exe Converter]
|
||||
::
|
||||
::YAwzoRdxOk+EWAjk
|
||||
::fBw5plQjdCuDJE6L5kkgJBpXSTiYP3iqD7EZ+tTo++uVtgMUV+1f
|
||||
::YAwzuBVtJxjWCl3EqQJgSA==
|
||||
::ZR4luwNxJguZRRnk
|
||||
::Yhs/ulQjdF+5
|
||||
::cxAkpRVqdFKZSzk=
|
||||
::cBs/ulQjdF+5
|
||||
::ZR41oxFsdFKZSDk=
|
||||
::eBoioBt6dFKZSDk=
|
||||
::cRo6pxp7LAbNWATEpCI=
|
||||
::egkzugNsPRvcWATEpCI=
|
||||
::dAsiuh18IRvcCxnZtBJQ
|
||||
::cRYluBh/LU+EWAnk
|
||||
::YxY4rhs+aU+JeA==
|
||||
::cxY6rQJ7JhzQF1fEqQJQ
|
||||
::ZQ05rAF9IBncCkqN+0xwdVs0
|
||||
::ZQ05rAF9IAHYFVzEqQJQ
|
||||
::eg0/rx1wNQPfEVWB+kM9LVsJDGQ=
|
||||
::fBEirQZwNQPfEVWB+kM9LVsJDGQ=
|
||||
::cRolqwZ3JBvQF1fEqQJQ
|
||||
::dhA7uBVwLU+EWDk=
|
||||
::YQ03rBFzNR3SWATElA==
|
||||
::dhAmsQZ3MwfNWATElA==
|
||||
::ZQ0/vhVqMQ3MEVWAtB9wSA==
|
||||
::Zg8zqx1/OA3MEVWAtB9wSA==
|
||||
::dhA7pRFwIByZRRnk
|
||||
::Zh4grVQjdCuDJE6L5kkgJBpXSTiYP3iqD7EZ+tTo++uVtgMYTOdf
|
||||
::YB416Ek+ZG8=
|
||||
::
|
||||
::
|
||||
::978f952a14a936cc963da21a135fa983
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM 设置 Python 可执行文件路<E4BBB6><E8B7AF>?
|
||||
set PYTHON_EXECUTABLE=.\runtime\python.exe
|
||||
|
||||
REM 设置要运行的 Python 脚本
|
||||
set PYTHON_SCRIPT=start.py
|
||||
|
||||
REM 运行 Python 脚本
|
||||
%PYTHON_EXECUTABLE% %PYTHON_SCRIPT%
|
Loading…
Reference in New Issue