由于发布版本之后,Appstore一直都没有更新,就写了个脚本。
该脚本是需要所有信息更新完成才能触发
# 请求
import requests
# xpath
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)