python -m venv venv
Edge WebDriver链接在此,下载对应的浏览器的版本,然后改名为msedgedriver.exe放在\venv\Scripts下面。
main.py代码如下:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.options import Options
import time
import warnings
warnings.simplefilter('ignore',ResourceWarning)
options = Options()
options.add_argument("headless")
driver = webdriver.Edge(options=options)
driver.get("https://www.ablesci.com/site/login")
driver.find_element(By.ID,value="LAY-user-login-email").send_keys("[email protected]")
driver.find_element(By.ID,value="LAY-user-login-password").send_keys("xxxxxxxx")
# time.sleep(5)
driver.find_elements(By.CLASS_NAME,value="layui-btn")[1].click()
print('登录成功')
time.sleep(3)
try:
sign_button = driver.find_elements(By.CLASS_NAME,value="layui-btn-sm")[0]
if(sign_button):
sign_button.click()
print('签到成功')
with open('message.txt','a+',encoding = 'utf-8') as f:
f.write("签到成功 "+str(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"\n"))
except:
print('签到失败')
with open('message.txt','a+',encoding = 'utf-8') as f:
f.write("失败成功 "+str(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"\n"))
driver.quit()
可激活虚拟环境和运行main.py
call .\venv\Scripts\activate
python main.py
下面即可等待每天自动签到获取积分了。