MCPcopy Create free account
hub / github.com/LumingMelody/JS_reverse / feed

Function feed

red_book.py:21–66  ·  view source on GitHub ↗
(source_note_id, web_session, a1)

Source from the content-addressed store, hash-verified

19
20
21def feed(source_note_id, web_session, a1):
22 headers = {
23 "accept": "application/json, text/plain, */*",
24 "accept-language": "zh-CN,zh;q=0.9",
25 "cache-control": "no-cache",
26 "content-type": "application/json;charset=UTF-8",
27 "cookie": f"a1={a1}; web_session={web_session};",
28 "origin": "https://www.xiaohongshu.com",
29 "pragma": "no-cache",
30 "referer": "https://www.xiaohongshu.com/",
31 "sec-ch-ua": "\"Chromium\";v=\"112\", \"Google Chrome\";v=\"112\", \"Not:A-Brand\";v=\"99\"",
32 "sec-ch-ua-mobile": "?0",
33 "sec-ch-ua-platform": "\"Windows\"",
34 "sec-fetch-dest": "empty",
35 "sec-fetch-mode": "cors",
36 "sec-fetch-site": "same-site",
37 "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
38 "x-b3-traceid": "a31fffc0ee4f5d8f",
39 "x-s-common": "",
40 }
41 data = {"source_note_id": source_note_id}
42 exc = execjs.compile(open('./js_signature/xs20230531.js', 'r', encoding='utf-8').read())
43 xs_xt = exc.call('get_xs', '/api/sns/web/v1/feed', data, a1)
44 xs_xt['X-t'] = str(xs_xt['X-t'])
45 print(xs_xt)
46 headers.update(xs_xt)
47 feed = 'https://edith.xiaohongshu.com/api/sns/web/v1/feed'
48 resp = requests.post(url=feed, data=json.dumps(data, separators=(",", ":")), headers=headers).json()
49 print(resp['data']['items'][0])
50 result = resp['data']['items'][0]['note_card']
51 nickname = result['user']['nickname']
52 user_id = result['user']['user_id']
53 note_url = f"https://www.xiaohongshu.com/explore/{source_note_id}"
54 title = result['title']
55 desc = result['desc']
56 liked_count = result['interact_info']['liked_count']
57 comment_count = result['interact_info']['comment_count']
58 collected_count = result['interact_info']['collected_count']
59 share_count = result['interact_info']['share_count']
60 ts = result['time']
61 post_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(ts) / 1000))
62 print(nickname, user_id, note_url, title, desc, liked_count, comment_count, collected_count, share_count,
63 post_time)
64 ws.append([nickname, user_id, note_url, title, desc, liked_count, comment_count, collected_count, share_count,
65 post_time])
66 wb.save('./data/家电_.xlsx')
67
68
69if __name__ == '__main__':

Callers 1

red_book.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected