-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathdemo.py
73 lines (61 loc) · 2.21 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# _*_ coding: utf-8 _*_
# @Date: 3:21 下午
# @File: demo.py
# @Author: liyf
"""
todo: https://m.poizon.com/router/
破解得物产品列表页中请求参数 `sign`
接口: https://app.poizon.com/api/v1/h5/index/fire/index
- POST请求
- params中 `sign` 需要破解
通过搜索关键字 `sign:` 可以定位到加密函数在 `index.7cee99cc.js`文件第9296行,如下:
todo```
var n = C(e.params);
return e.params = L({
sign: n
}, e.params),
```
其中 `C(e.params)` 就是生成sign的入口,且e.params=发送post请求需要的参数。
接着就是常规操作,下断点,进入该函数之后,看下该函数做了什么操作,然后实行 `缺啥补啥` 的准则,扣js代码。
"""
import requests
from utils import *
def get_sign(page):
ctx = Utils(js_file_name='demo.js').read_js_file()
return ctx.call('get_sign', page)
def get_results(page):
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Origin': 'https://m.poizon.com',
'Referer': 'https://m.poizon.com/',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36',
}
sign = get_sign(page)
logger.info(f'第 {page} 页: {sign}')
json_data = {
'sign': sign,
'tabId': '',
'limit': 20,
'lastId': page,
'platform': 'h5',
'version': '4.73.0',
'isVisitor': False,
'newAdvForH5': True,
}
response = requests.post('https://app.poizon.com/api/v1/h5/index/fire/index', headers=headers, json=json_data)
return response.json()
def parse():
for page in range(1, 10):
results = get_results(page)
data_list = results['data']['hotList']
for data in data_list:
product = data['product']
title = product['title']
soldCountText = product['soldCountText']
price = int(product['price']) / 100
logoUrl = product['logoUrl']
print(f'产品名称: {title}\n价格: {price}\n销量: {soldCountText}\n图片地址: {logoUrl}')
print('===' * 35)
if __name__ == '__main__':
parse()