-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
自己的linux基础还是太差了,几行linux代码折腾了一天
- Loading branch information
Showing
4 changed files
with
87 additions
and
51 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,51 @@ | ||
from itertools import count | ||
import requests | ||
import logging | ||
import os | ||
import re | ||
import time | ||
import sys | ||
import time | ||
|
||
import requests | ||
import urllib3 | ||
|
||
# 关闭安全请求警告 | ||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||
|
||
logging.basicConfig(level=logging.INFO, | ||
filename=os.path.join(os.getcwd(), 'log.txt'), | ||
format='%(asctime)s - %(levelname)s: %(message)s') | ||
|
||
|
||
def checkCount(token): | ||
i=0 | ||
i = 0 | ||
while(True): | ||
i=i+1 | ||
i = i+1 | ||
# 请求url,解析变量值 | ||
response = requests.get( | ||
"https://www.yilibabyclub.com/malldetail.aspx?dataid=300406&giftid=8075&code=202206002", verify=False, proxies={'https': None}) | ||
count_str = re.findall("var giftcount = (\d+);", response.text) | ||
|
||
count_int = int(count_str[0]) | ||
print("执行第%s次,当前库存%s" %(i,count_int)) | ||
|
||
logging.info("执行第%s次,当前库存%s", i, count_int) | ||
|
||
if(count_int != 0): | ||
# 执行通知 | ||
data = {"title": "有货了", "desp":"赶快去抢啊,快点的"} | ||
url="https://sctapi.ftqq.com/"+token+".send" | ||
data=requests.post( | ||
url, params=data,proxies={'https': None}) | ||
data = {"title": "所选商品有货了", "desp": "所选设备已有,赶快去抢啊"} | ||
url = "https://sctapi.ftqq.com/"+token+".send" | ||
data = requests.post( | ||
url, params=data, proxies={'https': None}) | ||
break | ||
time.sleep(30) | ||
|
||
|
||
if __name__ == '__main__': | ||
# 输入了token值 | ||
if len(sys.argv)==2: | ||
print("开始执行库存监控") | ||
if len(sys.argv) == 2: | ||
logging.info("开始执行库存监控") | ||
checkCount(sys.argv[1]) | ||
elif len(sys.argv)==1: | ||
sendKey=input("请输入你的Server酱SendKey值:") | ||
print("开始执行库存监控") | ||
elif len(sys.argv) == 1: | ||
sendKey = input("请输入你的Server酱SendKey值:") | ||
logging.info("开始执行库存监控") | ||
checkCount(sendKey) | ||
else: | ||
print("本程序只支持1个参数,请勿多输") | ||
logging.info("本程序只支持1个参数,请勿多输") |
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
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