Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lrsgzs authored Jun 30, 2023
1 parent 3857762 commit 88739d8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 9 deletions.
27 changes: 21 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys


if sys.platform == "win32":
import ctypes
import winreg
Expand All @@ -17,8 +19,16 @@ def is_admin():

from PySide2 import QtWidgets
from selenium import webdriver

from selenium.webdriver.edge import options as edge_option
from selenium.webdriver.chrome import options as chrome_option
from selenium.webdriver.firefox import options as firefox_option
from selenium.webdriver.safari import options as safari_option
from selenium.webdriver.ie import options as ie_option

from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
import selenium.common.exceptions
import time
import os
import pickle
Expand All @@ -34,6 +44,7 @@ def __init__(self, parent=None):

self.dialog = None
self.driver = None
self.option = None
self.info = {"date": "", "time": "", "ticket": "", "money": "", "id": ""}

self.getticket.clicked.connect(self.get_ticket)
Expand Down Expand Up @@ -121,7 +132,6 @@ def get_ticket(self):
break

webdrivers = [webdriver.ChromiumEdge, webdriver.Chrome, webdriver.Firefox, webdriver.Safari, webdriver.Ie]

self.driver = webdrivers[self.webdriver_select.currentIndex()]()
self.driver.maximize_window()
self.driver.get("https://www.globalinterpark.com/user/signin")
Expand All @@ -136,15 +146,20 @@ def get_ticket(self):
self.driver.get(self.url.toPlainText())

if self.is_open_timeup.checkState():
timeup2 = self.timeup_hour.text() + ":" + str(int(self.timeup_min.text()) - 1) + ":55"
timeup2 = self.timeup_hour.text() + ":" + self.timeup_min.text()
while True:
if time.strftime("%H:%M:%S") == timeup2:
if time.strftime("%H:%M") == timeup2:
break

if self.is_reload.checkState():
self.driver.refresh()
time.sleep(2)
self.driver.set_page_load_timeout(int(float(self.timeout_sec.text())))
try:
self.driver.refresh()
except selenium.common.exceptions.TimeoutException:
print("页面加载太拉了,停了算了")
self.driver.execute_script("window.stop()")
self.driver.switch_to.frame(self.driver.find_element(By.ID, "product_detail_area"))
self.driver.set_page_load_timeout(300)

wait_select_dom = self.driver.find_element(By.ID, "play_date")
wait_select_dom.click()
Expand Down Expand Up @@ -290,7 +305,7 @@ def get_ticket(self):
f"座位: {self.info['ticket']}\n" \
f"花的钱: {self.info['money']}\n" \
f"ID: {self.info['id']}"
path = os.path.join(self.get_desktop(), txt_filename)
path = os.path.join(self.get_desktop_or_user_folder(), txt_filename)
with open(path, "w", encoding="utf-8") as file:
file.write(text)

Expand Down
35 changes: 33 additions & 2 deletions main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>500</height>
<height>530</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -29,7 +29,7 @@
</font>
</property>
<property name="text">
<string># GlobalInterPark 抢票软件</string>
<string># GlobalInterPark 抢票软件2.0</string>
</property>
<property name="textFormat">
<enum>Qt::MarkdownText</enum>
Expand Down Expand Up @@ -959,6 +959,35 @@
<string>是否刷新</string>
</property>
</widget>
<widget class="QLabel" name="label_22">
<property name="geometry">
<rect>
<x>10</x>
<y>500</y>
<width>141</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>加载超时时间: 秒</string>
</property>
</widget>
<widget class="QLineEdit" name="timeout_sec">
<property name="geometry">
<rect>
<x>100</x>
<y>500</y>
<width>31</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>123</string>
</property>
<property name="maxLength">
<number>3</number>
</property>
</widget>
<zorder>label_18</zorder>
<zorder>label_12</zorder>
<zorder>label_8</zorder>
Expand Down Expand Up @@ -1006,6 +1035,8 @@
<zorder>start_min</zorder>
<zorder>start_sec</zorder>
<zorder>is_reload</zorder>
<zorder>label_22</zorder>
<zorder>timeout_sec</zorder>
</widget>
</widget>
<tabstops>
Expand Down
13 changes: 12 additions & 1 deletion main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(400, 500)
MainWindow.resize(400, 530)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
Expand Down Expand Up @@ -335,6 +335,13 @@ def setupUi(self, MainWindow):
self.is_reload = QtWidgets.QCheckBox(self.centralwidget)
self.is_reload.setGeometry(QtCore.QRect(50, 76, 71, 20))
self.is_reload.setObjectName("is_reload")
self.label_22 = QtWidgets.QLabel(self.centralwidget)
self.label_22.setGeometry(QtCore.QRect(10, 500, 141, 21))
self.label_22.setObjectName("label_22")
self.timeout_sec = QtWidgets.QLineEdit(self.centralwidget)
self.timeout_sec.setGeometry(QtCore.QRect(100, 500, 31, 20))
self.timeout_sec.setMaxLength(3)
self.timeout_sec.setObjectName("timeout_sec")
self.label_18.raise_()
self.label_12.raise_()
self.label_8.raise_()
Expand Down Expand Up @@ -382,6 +389,8 @@ def setupUi(self, MainWindow):
self.start_min.raise_()
self.start_sec.raise_()
self.is_reload.raise_()
self.label_22.raise_()
self.timeout_sec.raise_()
MainWindow.setCentralWidget(self.centralwidget)

self.retranslateUi(MainWindow)
Expand Down Expand Up @@ -451,3 +460,5 @@ def retranslateUi(self, MainWindow):
self.days.setText(_translate("MainWindow", "1"))
self.label_18.setText(_translate("MainWindow", " : :"))
self.is_reload.setText(_translate("MainWindow", "是否刷新"))
self.label_22.setText(_translate("MainWindow", "加载超时时间: 秒"))
self.timeout_sec.setText(_translate("MainWindow", ""))

0 comments on commit 88739d8

Please sign in to comment.