(base64解码)地址:aHR0cHM6Ly9zdHUudHVsaW5ncHl0b24uY24vcHJvYmxlbS1kZXRhaWwvNC8=
先找到请求接口带有加密参数:
全局搜索Sign,找到参数生成位置
看到这就一目了然塞,知道参数是怎么构造生成的,不知道这段 JavaScript 代码没关系看下面ai解释
我们来调试一下代码
测试验证自己的猜想思路是否正确
验证结果对比:
时间戳:
import time
new_date=int(time.time()*1000)
sign:
import hashlib
md5=hashlib.md5()
data="tuling"+str(new_date)+str(1)
md5.update(data.encode('utf-8'))
sign=md5.hexdigest()
print(sign)
下面是完整的python代码:
import requests
import time
import hashlib
import randomheaders = {'accept': '*/*','accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6','cache-control': 'no-cache','cookie': #添加自己的cookie,'pragma': 'no-cache','priority': 'u=1, i','referer': 'https://stu.tulingpyton.cn/problem-detail/4/','sec-ch-ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
}sum=0
for i in range(1,21):new_date=int(time.time()*1000)md5=hashlib.md5()data="tuling"+str(new_date)+str(i)md5.update(data.encode('utf-8'))sign=md5.hexdigest()print(sign)params = {'page': i,'sign': sign,'_ts': new_date,}response = requests.get('https://stu.tulingpyton.cn/api/problem-detail/4/data/', params=params, headers=headers)print(response.json())for li in response.json()['current_array']:sum+=litime.sleep(random.randint(1,3))
print(sum)
运行结果:
哈哈哈收工