TLYPython签到2.0
本帖最后由 丶七年 于 2023-3-14 03:59 编辑import time
import requests
import base64
import json
from datetime import datetime
cookie="" 账号ck
token='' #验证码token
#http://www.bhshare.cn/imgcode/ 这里申请token
def imgcode_online(imgurl):
data = {
'token': token,
'type': 'online',
'uri': imgurl
}
response = requests.post('http://www.bhshare.cn/imgcode/', data=data)
print(response.text)
result = json.loads(response.text)
if result['code'] == 200:
print(result['data'])
return result['data']
else:
print(result['msg'])
return 'error'
def getmidstring(html, start_str, end):
start = html.find(start_str)
if start >= 0:
start += len(start_str)
end = html.find(end, start)
if end >= 0:
return html.strip()
def tly():
signUrl="https://tly30.com/modules/index.php"
hearder={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36','Cookie':cookie}
res=requests.get(url=signUrl,headers=hearder).text
signtime=getmidstring(res,'<p>上次签到时间:<code>','</code></p>')
timeArray = time.strptime(signtime, "%Y-%m-%d %H:%M:%S")
timeStamp = int(time.mktime(timeArray))
t = int(time.time())
if t-timeStamp>86400:
print("距上次签到时间大于24小时啦,可签到")
#获取验证码图片
captchaUrl="https://tly30.com/other/captcha.php"
signurl="https://tly30.com/modules/_checkin.php?captcha="
hearder={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36','Cookie':cookie}
res1=requests.get(url=captchaUrl,headers=hearder)
base64_data = base64.b64encode(res1.content)
oocr=imgcode_online('data:image/jpeg;base64,'+str(base64_data, 'utf-8'))
res2=requests.get(url=signurl+oocr.upper(),headers=hearder).text
print(res2)
else:
print("还未到时间!",t-timeStamp)
def main_handler(event, context):
tly()
if __name__ == '__main__':
tly()
Python TLY签到,可以挂云函数设置1小时、2小时进行签到,反正做了24小时是否到期验证
修改了下代码如下:
import time
import requests
import base64
import json
from datetime import datetime
cookie="" #账号cookie
token='' #验证码token
#token在http://www.bhshare.cn/imgcode/gettoken/ 自行申请
def imgcode_online(imgurl):
data = {
'token': token,
'type': 'online',
'uri': imgurl
}
response = requests.post('http://www.bhshare.cn/imgcode/', data=data)
print(response.text)
result = json.loads(response.text)
if result['code'] == 200:
print(result['data'])
return result['data']
else:
print(result['msg'])
return 'error'
def getmidstring(html, start_str, end):
start = html.find(start_str)
if start >= 0:
start += len(start_str)
end = html.find(end, start)
if end >= 0:
return html.strip()
def tly():
signUrl="https://tly30.com/modules/index.php"
hearder={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36','Cookie':cookie}
res=requests.get(url=signUrl,headers=hearder).text
signtime=getmidstring(res,'<p>上次签到时间:<code>','</code></p>')
timeArray = time.strptime(signtime, "%Y-%m-%d %H:%M:%S")
timeStamp = int(time.mktime(timeArray))
t = int(time.time())
if t-timeStamp>86400:
print("距上次签到时间大于24小时啦,可签到")
done=False
while(done==False):
#获取验证码图片
captchaUrl="https://tly30.com/other/captcha.php"
signurl="https://tly30.com/modules/_checkin.php?captcha="
hearder={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36','Cookie':cookie}
res1=requests.get(url=captchaUrl,headers=hearder)
base64_data = base64.b64encode(res1.content)
oocr=imgcode_online('data:image/jpeg;base64,'+str(base64_data, 'utf-8'))
res2=requests.get(url=signurl+oocr.upper(),headers=hearder).text
print(res2)
findresult=res2.find("流量")
if findresult!=-1:
done=True
else:
done=False
print("未签到成功,沉睡3秒再来一次")
time.sleep(3)
else:
print("还未到时间!",t-timeStamp)
def main_handler(event, context):
tly()
if __name__ == '__main__':
tly()
本次更新内容:
1、签到做了循环,判断签到成功,这样就不用傻等每一小时了
2、while循环真好用 :)
3、目前网站被墙,云函数换香港等地区即可解决哈
好像执行获取时间戳,会有时差问题,有8小时的差距
如果你遇到了,请将86400改为57600{:301_997:} 丶七年 发表于 2023-2-24 11:45
我是在Python3.6环境下写的
另外验证码识别不是100%的识别率,多运行几次,看看输出结果
日志输出
FunctionCompute python3 runtime inited.
FC Invoke Start RequestId: 1-63f83b4d-e6426c2209e7e177276e3426
2023-02-24 12:21:33 1-63f83b4d-e6426c2209e7e177276e3426 hello world
FC Invoke End RequestId: 1-63f83b4d-e6426c2209e7e177276e3426
请求信息
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
本次更新内容:
1、签到做了循环,判断签到成功,这样就不用傻等每一小时了
2、while循环真好用 :)
是挂云涵数不用再设置定时触发器了吗? 刚试了下,好使。
云函数比较好啊 {:1_893:},谢谢分享 感谢分享好作品 谢谢。学习一下 验证码识别准确率高吗 申请token的地址不对 是这里 http://www.bhshare.cn/imgcode/gettoken 刚刚TLY手动签到完,就看到这篇文章了,明天试试看,感谢楼主! 云函数比较好啊