需要环境
selenium+chrome
推送到手机使用的是Bark这款app
推送到QQ使用的是Mirai+mirai-api-http
mirai-api-http插件的配置
#密钥
authKey: 自己设定密钥
#端口
port: 20003
#开启Websocket
enableWebsocket: true
#开启上报消息(非必要)
report:
enable: true
groupMessage:
report: true
destinations:
- http://localhost:5000/message
上代码
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import schedule
import json,requests
import sys
reload(sys)
sys.setdefaultencoding('utf8')
option = webdriver.ChromeOptions()
option.add_argument('--user-data-dir=/home/seluser/.config/google-chrome')
option.add_argument('detach=True')
driver = webdriver.Remote(
command_executor="http://localhost:4444/wd/hub",
desired_capabilities = option.to_capabilities()
)
url = 'https://pc.xuexi.cn/points/login.html?ref=https%3A%2F%2Fpc.xuexi.cn%2Fpoints%2Fmy-points.html'
auth_url = 'http://localhost:20003/auth'
verify_url = 'http://localhost:20003/verify'
send_url = 'http://localhost:20003/sendGroupMessage'
data = json.dumps({"authKey": "lyh20000324"})
r = requests.post(auth_url,data)
print(r.content)
print(data)
session = json.loads(r.text).get('session')
verify_data = json.dumps({"sessionKey": session,"qq": 1991808659})
r1 = requests.post(verify_url,verify_data)
print(r1.content)
print(verify_data)
driver.get(url)
def watch():
driver.refresh()
print(driver.find_elements_by_class_name('my-points-points')[1].text)
if int(driver.find_elements_by_class_name('my-points-points')[1].text) < 36:
send_data = json.dumps({"sessionKey": session,"target": 319593985,"messageChain": [{ "type": "Plain", "text": '当天分数'+driver.find_elements_by_class_name('my-points-points')[1].text+',该学习了'}]})
r2 = requests.post(send_url,send_data)
posturl = 'https://api.day.app/S6GrEJXcK8ivQoL84h7Y6Z/'+'当天分数'+driver.find_elements_by_class_name('my-points-points')[1].text+',该学习了'
r3 = requests.get(posturl)
elif int(driver.find_elements_by_class_name('my-points-points')[1].text) == 42:
send_data = json.dumps({"sessionKey": session,"target": 319593985,"messageChain": [{ "type": "Plain", "text": '当天分数'+driver.find_elements_by_class_name('my-points-points')[1].text+',看看有没有题目可以答'}]})
r4 = requests.post(send_url,send_data)
posturl = 'https://api.day.app/S6GrEJXcK8ivQoL84h7Y6Z/'+'当天分数'+driver.find_elements_by_class_name('my-points-points')[1].text+',看看有没有题目可以答'
r5 = requests.get(posturl)
if driver.current_url == 'https://pc.xuexi.cn/points/my-points.html':
schedule.every(30).minutes.do(watch)
if __name__ == '__main__':
while True:
schedule.run_pending()