腾讯视频V力值签到2.4[2021.9.15]
导读
今天发现腾讯视频签到失败了。。还以为COOKIE失效了。。
更新了发现还是失败。。。看来腾讯又该代码了。。。还好改的不多。。
话不多说。。。代码附上
# -*- coding: utf8 -*-
import requests
import re
import time
from urllib.parse import quote
#tx_getVsToken:2019.12.1
def jiemi(str1):
i=5381
e=0
n=len(str1)
while e < n :
i = i + (i<<5) + ord(str1[e])
e=e+1
#print(i)
#print(i)
res = 2147483647 & i
#print(res)
return str(res);
#更新cookie
def renew_cookie(cookie_list):
#获取刷新cookie的地址,自动跳过更新失败的cookie
res = requests.get('https://vm.gtimg.cn/tencentvideo_v1/script/txv.core.js?v=20210720').text
url1 = re.search(r'authRefresh:o(.*?)",', res).group(1)
auth_url = 'https://access.video.qq.com'+url1[2:]
new_cookie_list = []
#循环更新cookie
for cookie1 in cookie_list:
try:
s = requests.session()
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.204 Safari/537.36','referer':'https://v.qq.com/','Cookie': cookie1}
this_time = int(round(time.time() * 1000))
cookies_arr = cookie1.split('; ')
for cookie2 in cookies_arr:
c1 = cookie2.split('=')
if c1[0] =='vqq_vusession': vqq_vusession = c1[1]
if c1[0] =='vqq_access_token': vqq_access_token = c1[1]
#print('vqq_vusession:'+vqq_vusession )
vqq_vusession1 =jiemi(vqq_vusession)
g_actk = jiemi(vqq_access_token)
#print('vqq_vusession加密后:'+vqq_vusession1 )
url0 = auth_url + '&type=qq&g_tk=&g_vstk='+vqq_vusession1+'&g_actk='+g_actk+'&_=' + str(this_time)
#print(url0)
res =s.get(url0,headers=headers).text
#print('访问结果1:'+res)
new_vus = re.search(r'vusession":"(.*?)","', res).group(1)
cookie2 = cookie1.replace(vqq_vusession,new_vus)
new_cookie_list.append(cookie2)
except Exception:
print('cookie更新失败【'+vqq_vuserid+'】,跳过。')
continue
return new_cookie_list
def start():
try:
s = requests.session()
###################需要修改的部分。
cookie1_list = ['。。。这里改成自己的COOKIE。。。']
serverj_url = 'https://sc.ftqq.com/SCU34934T12d12b0。。这里写自己的SERVER酱地址。07.send?text='
#################需要修改的部分结束。下面的不要动
this_time = int(round(time.time() * 1000))
login_url = 'https://vip.video.qq.com/fcgi-bin/comm_cgi?name=hierarchical_task_system&cmd=2&_=' + str(this_time)
new_cookie_list = renew_cookie(cookie1_list)
cookie2 = new_cookie_list[0]
headers2={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.204 Safari/537.36',
'referer':'https://v.qq.com/',
'Cookie': cookie2
}
#签到
res2 =s.get(login_url,headers=headers2).text
print('签到结果:'+res2)
except Exception as e:
print("地址访问失败,通知SERVER酱!")
#print(e)
requests.get(serverj_url + quote('腾讯视频自动签到失败~'+time.strftime('%Y.%m.%d',time.localtime(time.time()))) +'&desp='+quote('异常代码: '+str(e)))
def main_handler(event, context):
return start()
if __name__ == '__main__':
start()复制代码
发之前测试过了。因该不会有问题。