Skip to content

Commit

Permalink
完全体docker
Browse files Browse the repository at this point in the history
自己的linux基础还是太差了,几行linux代码折腾了一天
  • Loading branch information
roiding committed Feb 21, 2022
1 parent 8220765 commit 7231708
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 51 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ COPY jiankong.py jiankong.py
COPY start.sh start.sh


RUN pip install requests && chmod +x start.sh && mkdir -p /usr/yili-carebaby-game/logs
RUN pip install requests &&chmod +x start.sh&& mkdir -p /usr/yili-carebaby-game/logs

ENTRYPOINT /usr/yili-carebaby-game/start.sh
CMD ["/usr/yili-carebaby-game/start.sh"]
40 changes: 24 additions & 16 deletions jiankong.py
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个参数,请勿多输")
71 changes: 41 additions & 30 deletions shuafen.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
import requests
import time
import logging
import os
import random
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(), 'logs/shuafen.log'),
format='%(asctime)s - %(levelname)s: %(message)s')

game_level = 1
curr_score=0
#有4000个钻石就停止
curr_score = 0
# 有4000个钻石就停止


def start_game(authorization):
global game_level,curr_score
global game_level, curr_score
while(curr_score <= 4000):
# 请求头
header = {'Host': 'babyclub.msxapi.digitalyili.com', 'Connection': 'keep-alive',
'Accept': 'application/json, text/plain, */*',
# 修改此处为自己的微信auth
'Authorization': 'XXXX',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat',
'Content-Type': 'application/json;charset=UTF-8',
'Sec-Fetch-Site': 'same-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://babyclub.msx.digitalyili.com//',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-us,en'}
header['Authorization']=authorization
'Accept': 'application/json, text/plain, */*',
# 修改此处为自己的微信auth
'Authorization': 'XXXX',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat',
'Content-Type': 'application/json;charset=UTF-8',
'Sec-Fetch-Site': 'same-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://babyclub.msx.digitalyili.com//',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-us,en'}
header['Authorization'] = authorization
response = requests.get(
"https://babyclub.msxapi.digitalyili.com/api/v1/game/play_auth", headers=header, verify=False)
# 提交分数token
score_token = response.json()['data']['score_token']
game_level = response.json()['data']['game_level']
print("当前进度:%s" %(game_level))
logging.info("当前进度:%s",game_level)
# 暂停60s 与游戏时间保持一致 防止被查
time.sleep(60)
request_data = {
Expand All @@ -46,20 +55,22 @@ def start_game(authorization):
request_data['auth_token'] = score_token
request_data['game_level'] = game_level+1
request_data['score'] = 5*random.randint(19, 28)
score_response=requests.post("https://babyclub.msxapi.digitalyili.com/api/v1/game/submit_score",
json=request_data, headers=header, verify=False)
print("%s:成绩已提交:分数为%s" %(game_level,request_data['score']))
curr_score=score_response.json()['data']['history_total_score']
print("当前共赚取%s钻石" %(curr_score))
score_response = requests.post("https://babyclub.msxapi.digitalyili.com/api/v1/game/submit_score",
json=request_data, headers=header, verify=False)
logging.info("%s:成绩已提交:分数为%s",game_level,request_data['score'])
curr_score = score_response.json()['data']['history_total_score']
logging.info("当前共赚取%s钻石",curr_score)
time.sleep(2)


if __name__ == '__main__':
# 输入了auth值
if len(sys.argv)==2:
print("开始执行钻石获取")
if len(sys.argv) == 2:
logging.info("开始执行钻石获取")
start_game(sys.argv[1])
elif len(sys.argv)==1:
authorization=input("请输入你的微信登录Authorization值:")
print("开始执行钻石获取")
elif len(sys.argv) == 1:
authorization = input("请输入你的微信登录Authorization值:")
logging.info("开始执行钻石获取")
start_game(authorization)
else:
print("本程序只支持1个参数,请勿多输")
logging.info("本程序只支持1个参数,请勿多输")
23 changes: 20 additions & 3 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
#!/bin/sh

trap closePython SIGTERM


if [ $AUTHORIZATION ]
then

python ./shuafen.py $AUTHORIZATION &>./logs/shuafen.log &
python ./shuafen.py $AUTHORIZATION &>>./logs/runtime.log &
pid1=$!
fi
echo "pid1:${pid1}"

if [ $SENDKEY ]
then
python ./jiankong.py $SENDKEY &>./logs/jiankong.log &
python ./jiankong.py $SENDKEY &>>./logs/runtime.log &
pid2=$!
fi
echo "pid2:${pid2}"

closePython(){
if [ -n "${pid1}" -o -d "/proc/${pid1}" ]]
then
kill ${pid1}
fi
if [ -n "${pid2}" -o -d "/proc/${pid2}" ]]
then
kill ${pid2}
fi
}

while true
do
do

if [ -n "${pid1}" -o -d "/proc/${pid1}" ] || [ -n "${pid2}" -o -d "/proc/${pid2}" ]
then
sleep 1s
Expand Down

0 comments on commit 7231708

Please sign in to comment.