0 引言
想吃汉堡王了,半价汉堡还要签到,写了个程序想着可以在手机上运行,想吃汉堡就方便了。准备用termux安装python跑程序。
安装termux后想下载python没有下载成功,提示没找到,然后查阅资料让进行更新,但是更新也是502网关找不到。
1 更换源
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' $PREFIX/etc/apt/sources.list
sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@' $PREFIX/etc/apt/sources.list.d/game.list
sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX/etc/apt/sources.list.d/science.list
apt update && apt upgrade
来自:Termux | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
PS:建议不进行apt upgrade
这一步,因为现在就可以下了,更新就很慢很卡。
2 python下载及设置
下载python
pkg install python
开启储存权限
termux-setup-storage
弹出提示框就直接同意
ls
即可发现系统文件夹,然后就可以正常python一样操作了。
3汉堡王签到代码
反正也没人看我简书,把代码贴上面也比较方便,算bonus吧。
import requests
import json
import time
import datetime
import random
def send(nowCycle,clockIndex):
header={
'Host': 'scrm.bkchina.cn',
'Connection': 'keep-alive',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; VOG-AL00 Build/HUAWEIVOG-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/3171 MMWEBSDK/20211001 Mobile Safari/537.36 MMWEBID/9352 MicroMessenger/8.0.16.2040(0x2800105D) Process/toolsmp WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Origin': 'https://scrm.bkchina.cn',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://scrm.bkchina.cn/scrm-bk-wechat/view/punchClock/alarm_clock.html?clockCode=JM6H6N4D249&v={}'.format(datetime.datetime.now().strftime('%Y%m%d%H%M%S')),
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en-CN;q=0.8,en-US;q=0.7,en;q=0.6',
'Cookie': Cookie
}
params={
'clockCode':'JM6H6N4D249',
'clockType':1,
'clockIndex':clockIndex,
'nowCycle':nowCycle
}
url='https://scrm.bkchina.cn/scrm-bk-wechat/clockController/clickIn.do'
print(requests.post(url=url,headers=header,data=params).text)
def main(nowCycle):
for clockIndex in range(1,8):
time.sleep(random.randint(10,20))
print(nowCycle,clockIndex)
send(nowCycle,clockIndex)
# nowCycle好像可以循环利用
nowCycle=input('Please input the nowCycle\n')
main(nowCycle)