猿人学第12题-js-base64

This commit is contained in:
luzhisheng 2022-04-07 16:50:11 +08:00
parent b760a6b353
commit 969ef2c78b
3 changed files with 50 additions and 0 deletions

BIN
img/73.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -0,0 +1,21 @@
## 任务抓取这5页的数字计算加和并提交结果
https://match.yuanrenxue.com/match/12
查看请求地址
https://match.yuanrenxue.com/api/match/12?page=1&m=eXVhbnJlbnh1ZTE%3D
其中m是加密参数
m=eXVhbnJlbnh1ZTE%3D
打断点调试
![debugger](../img/73.png)
"m": btoa('yuanrenxue' + window.page)
很简单,直接上python代码
[最后代码实现](实例12.py "js代码4")

View File

@ -0,0 +1,29 @@
import requests
import base64
import json
def get_num():
num = 0
for i in range(1, 6):
con_str = 'yuanrenxue' + str(i)
ba_str = base64.b64encode(con_str.encode()).decode()
url = f"https://match.yuanrenxue.com/api/match/12?page={i}&m={ba_str}"
Headers = {
"user-agent": "yuanrenxue.project",
"cookie": "Hm_lvt_c99546cf032aaa5a679230de9a95c7db=1648698333,1648863299; "
"Hm_lvt_9bcbda9cbf86757998a2339a0437208e=1648718340,1648863297; "
"no-alert3=true; m=155; tk=7332741390523673465; sessionid=ac0xs5o2sopkirmvude3epvr8uzo8w66;"
" Hm_lpvt_9bcbda9cbf86757998a2339a0437208e=1649313675; "
"Hm_lpvt_c99546cf032aaa5a679230de9a95c7db=1649316025"
}
res = requests.get(url=url, headers=Headers)
res_dict = json.loads(res.text)
data = res_dict.get('data')
for i in data:
num += i['value']
print(num)
get_num()