1、整体思路
先抓取homeFeed的100条Feed作为基础数据

再抓取feed详情中的html,从html解析出topicId

再抓取Topic详情,抓取topic页html中的关联Topic,接口中的topic名称,点赞数、访问数等

循环2~3步骤。
2、基于 superagent 和 Puppeteer
因为小红书详情页面的数据存在多重防爬机制,因此先简单用 puppeteer 模拟页面请求抓取,获取_at参数。
3、快速开始
1.根目录执行

npm install

2.打开mogodb服务,并新建./config/db.js,参考如下:

module.exports = {
  user: 'tinyredbook', // mogodb用户名
  pwd: 'xxxxxx', // mogodb密码
  host: '127.0.0.1', // mogodb host地址,端口默认27017
};

3.根目录执行

node index.js

4、小红书App SIGN 算法 Python 版本(备份,或许会用到)

#coding:utf-8
import hashlib


def md5hex(word):
    if isinstance(word, unicode):
        word = word.encode("utf-8")
    elif not isinstance(word, str):
        word = str(word)
    m = hashlib.md5()
    m.update(word)
    return m.hexdigest()


#参数名
paramas_name=[
    'android_id',
    'channel',
    'deviceId',
    'device_fingerprint',
    'imei',
    'lang',
    'password',
    'phone',
    'platform',
    'sid',
    'start',
    't',
    'type',
    'versionName',
    'zone'
    ]


#按参数名顺序传入参数值列表,无参数名留空值
def get_sign(paramas_value):
    key=''
    for index,item in enumerate(paramas_value):
        if item!='':
            key=key+paramas_name[index]+'%3D'+item
    deviceId=paramas_value[2]
    v1_2 = bytearray(key, 'utf-8')
    v5_1 = ''
    v3_2 = 0
    v2 = 0
    v4_1=bytearray(deviceId, 'utf-8')

    while v2<len(v1_2):
        v5_1 = v5_1 + str(v1_2[v2] ^ v4_1[v3_2 ])
        v3_2 = (v3_2 + 1) % len(v4_1)
        v2 = v2 + 1

    sign=md5hex(md5hex(v5_1)+deviceId)
    return sign

后续思路会继续更新,欢迎感兴趣的读者联系飞机。

Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐