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

# -*- 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)

在这里插入图片描述

下载到本地的

# -*- 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)

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

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐