小红书视频链接,下载原视频分析。有个需求是小红书链接,视频下载到本地

直接上代码,抓包分析了半天,走了不少弯路,果然 朴实无华 才是最优解

python 复制代码
# -*- coding: utf-8 -*-
# author: da_pangzi
# datetime: 2024/12/11 16:50 
# ide: PyCharm
import requests


headers = {
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "priority": "u=0, i",
    "sec-ch-ua": "\"Google Chrome\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "document",
    "sec-fetch-mode": "navigate",
    "sec-fetch-site": "none",
    "sec-fetch-user": "?1",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
}

url = 'https://www.xiaohongshu.com/explore/6736be40000000001b012bf8?xsec_token=ABc_-Jlz_TFVL_yoP0s-gPQi3EYGGrt24dSY2XRfBRkEk=&xsec_source=pc_feed'
response = requests.get(url, headers=headers)

print(response.text)
print(response)

下载到本地的

python 复制代码
# -*- coding: utf-8 -*-
# author: da_pangzi
# datetime: 2024/12/11 16:52 
# ide: PyCharm
import requests

url = "https://sns-video-al.xhscdn.com/stream/110/258/01e736be401b382d01037001932dd76d83_258.mp4"

response = requests.get(url, stream=True)
with open("video.mp4", "wb") as f:
    f.write(response.content)

其他的批量下载的,做一些提取的 操作就可以了。

相关推荐
会员源码网3 小时前
Python中生成器函数与普通函数的区别
python
Java水解4 小时前
Python开发从入门到精通:Web框架Django实战
后端·python
曲幽5 小时前
FastAPI + PostgreSQL 实战:给应用装上“缓存”和“日志”翅膀
redis·python·elasticsearch·postgresql·logging·fastapi·web·es·fastapi-cache
Lupino8 小时前
别再只聊 AI 写代码了:技术负责人要把“变更治理”提到第一优先级
python·docker·容器
Flittly10 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(6)Context Compact (上下文压缩)
python·agent
曲幽20 小时前
FastAPI + PostgreSQL 实战:从入门到不踩坑,一次讲透
python·sql·postgresql·fastapi·web·postgres·db·asyncpg
用户8356290780511 天前
使用 C# 在 Excel 中创建数据透视表
后端·python
码路飞1 天前
FastMCP 实战:一个 .py 文件,给 Claude Code 装上 3 个超实用工具
python·ai编程·mcp
dev派1 天前
AI Agent 系统中的常用 Workflow 模式(2) Evaluator-Optimizer模式
python·langchain
前端付豪1 天前
AI 数学辅导老师项目构想和初始化
前端·后端·python