diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3a8605 --- /dev/null +++ b/.gitignore @@ -0,0 +1,368 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +#Set by qhy040404 +test.py +my.py + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ +[Oo]utput/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/Library.pyproj b/Library.pyproj new file mode 100644 index 0000000..c6a7d12 --- /dev/null +++ b/Library.pyproj @@ -0,0 +1,55 @@ + + + Debug + 2.0 + ae783c08-ec51-4dfc-9548-e568c6d4367d + . + + + + + . + . + Library + Library + + + true + false + + + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Library.sln b/Library.sln new file mode 100644 index 0000000..2f4fced --- /dev/null +++ b/Library.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "Library", "Library.pyproj", "{AE783C08-EC51-4DFC-9548-E568C6D4367D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AE783C08-EC51-4DFC-9548-E568C6D4367D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE783C08-EC51-4DFC-9548-E568C6D4367D}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B29C1CDF-4CE6-40D9-9994-C61C439BF33A} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..bc8f372 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# 大连理工大学图书馆自动预约座位小程序 + +Forked from [ShuaichiLi/DLUT-library-auto-reservation](https://github.com/ShuaichiLi/DLUT-library-auto-reservation) + +## 特性 +- 如果预约成功,程序会弹窗提示“预约xxx成功” +- 如果失败,则无弹窗 + +## 做出的修改 +- 去掉了页面的滑动,当前可以精确定位一个座位(代码量直接大幅下降doge) + +## 依赖项 +- [Chromedriver](https://chromedriver.chromium.org/downloads) 记得下载对应版本,解压到```/driver```文件夹里 +- [Python](https://www.python.org/downloads/) +- selenium (推荐使用[pip](https://pip.pypa.io/en/stable/installation/)) + - ```pip install -U selenium``` (For Linux) + - ```py -m pip install -U selenium``` (For Windows) + + +- 不下依赖包用个der啊 + + ![](files/dddd.jpg) + +## 使用 +- 通过修改```main.py```中```user_id```和```password```来设置账号密码 +- 修改```room_id```字段选择对应房间,我只注释了令希的,平时不去博川 +- 修改```favorSeats```字段来设定自己喜欢的座位(群) + -座位号两边需要加' ',不可省略(str字符串) + +## 未来(神tm未来) +- 可能以后会打包成程序 diff --git a/driver/chromedriver.exe b/driver/chromedriver.exe new file mode 100644 index 0000000..0e49805 Binary files /dev/null and b/driver/chromedriver.exe differ diff --git a/files/dddd.jpg b/files/dddd.jpg new file mode 100644 index 0000000..98cbdee Binary files /dev/null and b/files/dddd.jpg differ diff --git a/files/picture1.jpg b/files/picture1.jpg new file mode 100644 index 0000000..b2af872 Binary files /dev/null and b/files/picture1.jpg differ diff --git a/files/picture2.png b/files/picture2.png new file mode 100644 index 0000000..075d978 Binary files /dev/null and b/files/picture2.png differ diff --git a/src/functiontest.py b/src/functiontest.py new file mode 100644 index 0000000..072c1b4 --- /dev/null +++ b/src/functiontest.py @@ -0,0 +1,33 @@ +# coding=gbk +import time +import tkinter.messagebox +from selenium import webdriver +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.keys import Keys + + +browser = webdriver.Chrome(executable_path='driver/chromedriver.exe') +browser.maximize_window() + +browser.get('http://seat.lib.dlut.edu.cn/yanxiujian/client/orderSeat.php?method=addSeat&room_id=208&area_id=32') +today_button = browser.find_element_by_id('todayBtn') +today_button.click() +tomorrow_button = browser.find_element_by_id('nextDayBtn') +tomorrow_button.click() +time.sleep(1) + +allTabs = browser.find_elements_by_css_selector("i[class='seat-label']") +for tab in allTabs: + favorSeats = ['286', '288', '290'] + if tab.text in favorSeats: + current_seat = tab.text + tab.click() + confirm_button = browser.find_element_by_id('btn_submit_addorder') + try: + time.sleep(0.5) + confirm_button.click() + tkinter.messagebox.showinfo("ѧͼԶԤԼλС","ԤԼ%sɹ" % current_seat) + break + except: + continue +time.sleep(2) diff --git a/src/functiontest2.py b/src/functiontest2.py new file mode 100644 index 0000000..203bfd2 --- /dev/null +++ b/src/functiontest2.py @@ -0,0 +1,5 @@ +#coding=gbk +#import tkinter +import tkinter.messagebox +current_seat = '288' +tkinter.messagebox.showinfo("1","2 %s 3" % current_seat) \ No newline at end of file diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..7882647 --- /dev/null +++ b/src/main.py @@ -0,0 +1,75 @@ +# coding=utf-8 +''' +main +@author: Shuaichi Li +@editor: qhy040404 +@email: shuaichi@mail.dlut.edu.cn +@editor.email: qhy040404@mail.dlut.edu.cn +@date: 2022/03/19 15:44 +''' + +# import +import time +import tkinter.messagebox +from selenium import webdriver +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.keys import Keys + +user_id = '学号' +password = '密码' + +browser = webdriver.Chrome(executable_path='driver/chromedriver.exe') +browser.maximize_window() + +'''登录''' +browser.get("https://sso.dlut.edu.cn/cas/login?service=http://seat.lib.dlut.edu.cn/yanxiujian/client/login.php?redirect=index.php") +input_userid = browser.find_element_by_id('un') +input_userid.send_keys(user_id) +input_password = browser.find_element_by_id('pd') +input_password.send_keys(password) +login_button = browser.find_element_by_class_name('login_box_landing_btn') +login_button.click() + +'''更改想要去的房间号,选取第二天的座位图''' +'''对应房间号:(以下均为令希) +201:180 +202:181 +301:207 +302:208 +401:205 +402:206 +501:203 +502:204 +601:201 +602:202 +202电子阅览区:242 +''' +browser.get('http://seat.lib.dlut.edu.cn/yanxiujian/client/orderSeat.php?method=addSeat&room_id=208&area_id=32') +today_button = browser.find_element_by_id('todayBtn') +today_button.click() +tomorrow_button = browser.find_element_by_id('nextDayBtn') +tomorrow_button.click() +time.sleep(1) + +'''与原作者采用了不一样的方法,可以精确定位想要的位置''' +'''在favorSeats中设定自己喜欢的位置''' +allTabs = browser.find_elements_by_css_selector("i[class='seat-label']") +for tab in allTabs: + favorSeats = ['286', '288', '290'] + if tab.text in favorSeats: + current_seat = tab.text + tab.click() + confirm_button = browser.find_element_by_id('btn_submit_addorder') + try: + time.sleep(0.5) + confirm_button.click() + tkinter.messagebox.showinfo("大连理工大学图书馆自动预约座位小程序","预约%s成功" % current_seat) + break + except: + continue +time.sleep(2) + +'''注销操作并关闭窗口''' +browser.get("http://seat.lib.dlut.edu.cn/yanxiujian/client/loginOut.php") +time.sleep(2) +browser.close() \ No newline at end of file diff --git a/src/run.bat b/src/run.bat new file mode 100644 index 0000000..7a84f97 --- /dev/null +++ b/src/run.bat @@ -0,0 +1 @@ +python main.py \ No newline at end of file