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

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

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)

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

相关推荐
言乐69 小时前
Python实现建造微服务商城后台
开发语言·python·算法·微服务·架构
fenglllle10 小时前
chromadb emmbedding 向量检索
人工智能·python·embedding
cui_ruicheng10 小时前
Python从入门到实战(六):非序列容器
开发语言·python
飞猪~10 小时前
Langchain python版本 LLM 重要函数invoke,ainvoke,stream,astream,batch,abatch
python·langchain·batch
沙蒿同学11 小时前
当古诗词遇上 AI:从 38 万句诗词中取一个好名字
python·算法·架构
xxie12379411 小时前
Python装饰器与语法糖
开发语言·python
CClaris11 小时前
大模型量化从0到1(五):GPTQ 原理详解 + 从零量化一个真实大模型
人工智能·python·算法·机器学习
Railshiqian12 小时前
UserPickerActivity 内部逻辑分析
开发语言·python
一tiao咸鱼12 小时前
前端转 agent # 02 - FastAPI 框架入门与原理
前端·python
Yolo566Q12 小时前
Noah-MP陆面过程模型建模方法与站点、区域模拟实践技术应用
开发语言·python