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

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

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)

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

相关推荐
WiKiLeaks_successor4 分钟前
Scipy库里的众数函数不严谨,我把它重构了。
python·scipy
傻啦嘿哟9 分钟前
房产数据对比爬虫:同时爬取链家+贝壳+安居客,做房价横向对比
python
小静AI工程实验室13 分钟前
JS 逆向接口 ID 变了?Python 与 Node.js 复现 JSON 大整数精度丢失
javascript·python·node.js
李航198316 分钟前
用 DeepDraw 几何引擎开发建筑设计软件(五):创建选择工具
python·3d
Metaphor69221 分钟前
使用 Python 设置 Excel 行列自适应 【代码示例】
python·excel
花酒锄作田9 小时前
FastAPI 使用 session 认证
python·fastapi
lsswear9 小时前
Python 并发 线程
开发语言·python
Ivanqhz10 小时前
MLIR OpBuilder
开发语言·python·mlir
威联通安全存储11 小时前
TS-h2287XU-RP 在家电制造总装与质检数据场景的部署
python·制造
泡泡鱼(敲代码中)12 小时前
Python 字符串 str 完整学习笔记
python·学习