(source_note_id)
| 47 | |
| 48 | |
| 49 | def get_comment(source_note_id): |
| 50 | get_xs(source_note_id) |
| 51 | response = requests.get( |
| 52 | f'https://edith.xiaohongshu.com/api/sns/web/v2/comment/page?note_id={source_note_id}&cursor=', |
| 53 | headers=headers).json() |
| 54 | print(response) |
| 55 | while response['data']['has_more']: |
| 56 | comments = response['data']['comments'] |
| 57 | for comment in comments: |
| 58 | nick_name = comment['user_info']['nickname'] |
| 59 | content = comment['content'] |
| 60 | note_id = comment['note_id'] |
| 61 | ws.append([nick_name, content, note_id]) |
| 62 | print(nick_name, content, note_id) |
| 63 | cursor = response['data']['cursor'] |
| 64 | get_xs(source_note_id, cursor) |
| 65 | response = requests.get( |
| 66 | f'https://edith.xiaohongshu.com/api/sns/web/v2/comment/page?note_id={source_note_id}&cursor={cursor}', |
| 67 | headers=headers).json() |
| 68 | print(response) |
| 69 | wb.save(r'./data/red_book_comment.xlsx') |
| 70 | time.sleep(2) |
| 71 | |
| 72 | |
| 73 | # /api/sns/web/v2/comment/page?note_id=640070c90000000013001b92&cursor=64084ec5000000000b0300e6 |
no test coverage detected