爬虫练习---动态数据の小红书评论爬取
���录
一、找到你想要爬取的内容
1.在笔记中打开检查,可以在“预览”中找到小红书的评论内容
2.找到想要的请求后,在“标头”里找到你需要的URL、Cookie、User-Agent
二、写代码
三、爬取结果
一、找到你想要爬取的内容
1.在笔记中打开检查,可以在“预览”中找到小红书的评论内容
2.找到想要的请求后,在“标头”里找到你需要的URL、Cookie、User-Agent
二、写代码
import requests from time import sleep import csv import random def main(page, file, cursor): url = f'https://edith.xiaohongshu.com/api/sns/web/v2/comment/page?note_id=6576f2cb0000000016007e63&cursor={cursor}&top_comment_id=&image_formats=jpg,webp' headers = { 'Cookie':'*********', #用自己的Cookie,需要是登录后的Cookie 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0', } try: csvwriter.writerow(('评论内容',)) while page三、爬取结果
The End