HFUT招生办新消息循环等待Python程序

December 13, 2020 · 纯属折腾 · 开发笔记 · 363次阅读

万恶的招生办百年不出创新实验班成绩,这个脚本每5秒艹一次招生办的网站,已经跑了两天两夜三万多次请求了还是没出,愣是没在微信等到通知,乐死我了

import requests,json,threading,time
session = requests.session()
token = json.loads(session.post('http://bkzs.hfut.edu.cn/f/ajax_get_csrfToken',params={'n': '1'},
    headers={'X-Requested-With': 'XMLHttpRequest','X-Requested-Time': str(int(time.time()*1000))}).text)['data']
def get():
    global token
    response = session.post('http://bkzs.hfut.edu.cn/f/newsCenter/ajax_article_list',
        params={'pageNo': '1','pageSize': '1','categoryId': '833681b2bf25485cbe43bdf54b911407'},
        headers={'Csrf-Token': token,'X-Requested-Time': str(int(time.time()*1000)),'X-Requested-With': 'XMLHttpRequest'})
    data = json.loads(response.text)
    token = response.headers['Csrf-Token']
    print(time.asctime(time.localtime(time.time())) + ' ' + data['data']['page']['list'][0]['title'])
    if data['data']['page']['list'][0]['title'] != '合肥工业大学2020年创新实验班招生简章':
        session.get('https://sc.ftqq.com/YOUR_API_ID.send',
            params={'text': data['data']['page']['list'][0]['title'],'desp': data['data']['page']['list'][0]['description']})
        return
    threading.Timer(5,get).start()
get()

除声明外inSoraSky博客(http://www.sorasky.in/)所有内容均为本人所原创,转载时请注明来源!

喝杯水

PythonHFUT

最后编辑于1个月前

添加新评论