def get_article(): if not dataTimeOperation.is_get_data('articles'): return headers = { "Accept": "application/json", "Connection": "keep-alive", "DNT": "1", "Host": "www.xuexi.cn", "Referer": "https://www.xuexi.cn/4f5aa999a479568bf620109395d8fe56/69fe65d658afc891dd105e1ce9e5879d.html", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" } articles = requests.get(url='https://www.xuexi.cn/lgdata/u1ght1omn2.json', headers=headers) with open('./data/articles.json', 'w', encoding='utf-8') as f: f.write( json.dumps(json.loads(articles.content), ensure_ascii=False, indent=4)) dataTimeOperation.set_time('articles') print('--> 文章数据更新成功')
def get_video(): if not dataTimeOperation.is_get_data('videos'): return headers = { "Accept": "application/json", "Connection": "keep-alive", "DNT": "1", "Host": "www.xuexi.cn", "Referer": "https://www.xuexi.cn/a191dbc3067d516c3e2e17e2e08953d6/b87d700beee2c44826a9202c75d18c85.html", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" } articles = requests.get( url='https://www.xuexi.cn/lgdata/4d82ahlubmol.json', headers=headers) with open('./data/videos.json', 'w', encoding='utf-8') as f: f.write( json.dumps(json.loads(articles.content), ensure_ascii=False, indent=4)) dataTimeOperation.set_time('videos') print('--> 视频数据更新成功')