Created
October 1, 2021 13:03
-
-
Save theseann/d39e1bb8183813a236f212d917d16cd1 to your computer and use it in GitHub Desktop.
apple授权店库存监控,之前用的,备份一下
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#!/usr/bin/env python3 | |
import requests | |
import json | |
import time | |
def checkStore(url): | |
# 抓包并将查询请求的header填入 | |
headers = { | |
'User-Agent': '', | |
'Content-Type' : 'application/json', | |
'Authorizer-Appid' : '', | |
'Referer' : '', | |
'Accept-Encoding' : 'gzip', | |
'Charset' : 'utf-8', | |
'Host' : 'aar.yuanyuanke.cn', | |
} | |
r = requests.get(url,headers=headers) | |
print(r.text) | |
resJson = json.loads(r.text) | |
x = 0; | |
if resJson['errmsg'] == "success": | |
i = resJson['data']['total_count'] | |
comps = resJson['data']['list'] | |
for comp in comps: | |
if comp['is_have_store'] != 0: | |
x = x + 1 | |
print("🌟" + comp['name'] + "有货") | |
elif comp['is_have_store'] == 0: | |
print("👽" + comp['name'] + "无货") | |
return x; | |
def sendBot(msg): | |
# 飞书Bot webhook url | |
url = "" | |
headers = {'Content-Type': 'application/json'} | |
body = '{"msg_type":"text","content":{"text":"🌟' + msg + '个门店有货!!!!"}}' | |
r = requests.post(url,data = body.encode('utf-8'),headers=headers) | |
print(r.text) | |
if __name__ == "__main__": | |
blue = "https://aar.yuanyuanke.cn/api/h5app/wxapp/....." | |
white = "https://aar.yuanyuanke.cn/api/h5app/wxapp/....." | |
while(1): | |
print("----------------------------------------------------" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + " START "+"----------------------------------------------------") | |
x = checkStore(blue) | |
y = checkStore(white) | |
if x != 0 : | |
sendBot("[远峰蓝] " + str(x)) | |
if y != 0: | |
sendBot("[银色] " + str(x)) | |
print("----------------------------------------------------" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + " END "+"----------------------------------------------------") | |
time.sleep(300) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment