本帖最后由 丶七年 于 2023-3-14 03:59 编辑
[Python] 纯文本查看 复制代码 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[start:end].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小时是否到期验证
修改了下代码如下:
[Python] 纯文本查看 复制代码 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[start:end].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、目前网站被墙,云函数换香港等地区即可解决哈
|