Compare commits
5
Commits
aad451f5ce
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c24cf766d0 | ||
|
|
4b30d937f9 | ||
|
|
52bfb2f526 | ||
|
|
7d7f57b3f4 | ||
|
|
d70c14287b |
Generated
+10
@@ -0,0 +1,10 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# 已忽略包含查询文件的默认文件夹
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
Generated
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/buctAuthentication.iml" filepath="$PROJECT_DIR$/.idea/buctAuthentication.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3.13
|
||||||
+3
-3
@@ -22,9 +22,7 @@ class BUCTAU:
|
|||||||
|
|
||||||
self.USER_USERNAME = os.environ.get('BUCT_AUTHENTICATION_USERNAME')
|
self.USER_USERNAME = os.environ.get('BUCT_AUTHENTICATION_USERNAME')
|
||||||
self.USER_PASSWORD = os.environ.get('BUCT_AUTHENTICATION_PASSWORD')
|
self.USER_PASSWORD = os.environ.get('BUCT_AUTHENTICATION_PASSWORD')
|
||||||
self.USER_NAME = os.getlogin()
|
|
||||||
|
|
||||||
logging.info(f"USER now is {self.USER_NAME}")
|
|
||||||
logging.info(f"BUCTAU initialized with username:{self.USER_USERNAME}")
|
logging.info(f"BUCTAU initialized with username:{self.USER_USERNAME}")
|
||||||
logging.info(f"BUCTAU initialized with password:{self.USER_PASSWORD}")
|
logging.info(f"BUCTAU initialized with password:{self.USER_PASSWORD}")
|
||||||
# print(f"USER now is {self.USER_NAME}")
|
# print(f"USER now is {self.USER_NAME}")
|
||||||
@@ -75,7 +73,9 @@ class BUCTAU:
|
|||||||
try:
|
try:
|
||||||
driver.find_element(By.XPATH, '/html/body/main/section/div[1]/div[2]/input').send_keys(self.USER_USERNAME)
|
driver.find_element(By.XPATH, '/html/body/main/section/div[1]/div[2]/input').send_keys(self.USER_USERNAME)
|
||||||
driver.find_element(By.XPATH, '//*[@id="password"]').send_keys(self.USER_PASSWORD)
|
driver.find_element(By.XPATH, '//*[@id="password"]').send_keys(self.USER_PASSWORD)
|
||||||
driver.find_element(By.XPATH, '/html/body/main/section/div[1]/div[8]/button[1]').click()
|
login_button = driver.find_element(By.XPATH, '/html/body/main/section/div[1]/div[8]/button[1]')
|
||||||
|
driver.execute_script("arguments[0].click();", login_button)
|
||||||
|
# driver.find_element(By.ID,"login-account").click()
|
||||||
return True
|
return True
|
||||||
except selenium.common.exceptions.NoSuchElementException as e:
|
except selenium.common.exceptions.NoSuchElementException as e:
|
||||||
logging.info("NoSuchElementException: ", e)
|
logging.info("NoSuchElementException: ", e)
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ BUCT_AUTHENTICATION_PASSWORD=校园网密码
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
现在还是有点问题。比如说没有连接wifi的情况下,request的get会报ssl error然后直接退出。except也不好用。
|
~~现在还是有点问题。比如说没有连接wifi的情况下,request的get会报ssl error然后直接退出。except也不好用。~~
|
||||||
|
虽然我不知道为什么,但是最后还是改成用selenium检测登陆界面元素来做这事。虽然是反璞归真了,但是管他呢它跑得起来就行了。
|
||||||
我的解决方法就是service里面`Restart=always`,`RestartSec=60`。实测下来是能正常认证的。
|
我的解决方法就是service里面`Restart=always`,`RestartSec=60`。实测下来是能正常认证的。
|
||||||
|
|
||||||
用request来检测纯属闲的,本来还是拿selenium检测的。反正能跑管他呢。
|
用request来检测纯属闲的,本来还是拿selenium检测的。反正能跑管他呢。
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
def main():
|
||||||
|
print("Hello from buctauthentication!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[project]
|
||||||
|
name = "buctauthentication"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.13"
|
||||||
|
dependencies = []
|
||||||
@@ -5,7 +5,7 @@ from Authtication import BUCTAU
|
|||||||
def main():
|
def main():
|
||||||
"""Main function to run the script."""
|
"""Main function to run the script."""
|
||||||
authenticator = BUCTAU()
|
authenticator = BUCTAU()
|
||||||
driver = authenticator.init_driver_edge()
|
driver = authenticator.init_driver_chrome()
|
||||||
past_time = time.time()
|
past_time = time.time()
|
||||||
while True:
|
while True:
|
||||||
if time.time() - past_time > 10.0:
|
if time.time() - past_time > 10.0:
|
||||||
Reference in New Issue
Block a user