刘裕洪的Blog

  • 首页
  • 归档

  • 搜索
leetcode selenium docker 破解 mysql Spring Deepin 逆向 Android Smail 反编译 Linux ThinkPHP jQuery JavaScript html5 css python VMware Centos c# uwp 安朗 校园网 sofether 路由器 交叉编译

python监控学习强国分数

发表于 2020-07-26 | 分类于 selenium | 0 | 阅读次数 163

需要环境

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()
  • 本文作者: 刘裕洪
  • 本文链接: https://liuyuhong.ml/archives/python监控学习强国分数
  • 版权声明: 本博客所有文章除特别声明外,均采用CC BY-NC-SA 3.0 许可协议。转载请注明出处!
# leetcode # selenium # docker # 破解 # mysql # Spring # Deepin # 逆向 # Android # Smail # 反编译 # Linux # ThinkPHP # jQuery # JavaScript # html5 # css # python # VMware # Centos # c# # uwp # 安朗 # 校园网 # sofether # 路由器 交叉编译
修改selenium docker 默认30分钟关闭会话
leetcode 01
  • 文章目录
  • 站点概览
刘裕洪

刘裕洪

死宅一只 🎵爱听EDM 📷摄影萌新

28 日志
14 分类
26 标签
RSS
Github E-mail Twitter
Creative Commons
Links
  • Mystery0
  • 梧桐
© 2019 — 2021 刘裕洪
由 Halo 强力驱动
|
主题 - NexT.Mist v5.1.4