1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| import requests
from lxml import etree
from time import sleep
def requestLastVersionData(): try: header = {"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"} res = requests.get('https://apps.apple.com/cn/app/id******', headers=header) html = etree.HTML(res.text) html_data = html.xpath("//p[@class='l-column small-6 medium-12 whats-new__latest__version']/text()") return html_data[0] except Exception as e: print(e)
def robotNotice(): try: header = {"Content-Type": "application/json"} data = {"msgtype":"link","link":{"title":"已更新","text":"已更新","picUrl":"https://rencheng.cc/images/avatar.JPG","messageUrl":"https://apps.apple.com/cn/app/id******"}} requests.post('https://oapi.dingtalk.com/robot/send?access_token=******', json=data, headers=header, timeout=10) except Exception as e: print(e)
while True: version = requestLastVersionData() if version != None: if version != "版本 2.0.3": print("已更新") robotNotice() else: print("最新%s" % version) sleep(10)
|