吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2043|回复: 22
收起左侧

[学习记录] 请求删帖

  [复制链接]
sgbyg 发表于 2023-6-14 12:37
本帖最后由 sgbyg 于 2023-6-29 08:44 编辑

已无内容

免费评分

参与人数 2吾爱币 +3 热心值 +1 收起 理由
开始123 + 2 + 1 用心讨论,共获提升!
Zhaofeiyan + 1 用心讨论,共获提升!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

额微粒波地 发表于 2023-6-14 15:52
本帖最后由 额微粒波地 于 2023-6-14 15:59 编辑

[Python] 纯文本查看 复制代码
# 吾爱破解 - 额微粒波地
# pip install requests
# pip install json
# pip install tqdm
import json
import requests
from concurrent.futures import ThreadPoolExecutor
from tqdm import tqdm
url_data = 'https://api.smmdb.net/courses2/download/{}'
json_data = json.load(open('smmdb.json', 'r', encoding='utf-8'))


def download(url, course):
    with requests.get(url, stream=True) as response:
        response.raise_for_status()
        total_size = int(response.headers.get('content-length', 0))
        with open('{}.tar'.format(course['course']['header']['title']), 'wb') as f, tqdm(total=total_size, unit='B', unit_scale=True) as progress_bar:
            for chunk in response.iter_content(chunk_size=8192):
                if chunk:
                    f.write(chunk)
                    progress_bar.update(len(chunk))


def download_all(course_list):
    # max_workers 最大线程为4
    with ThreadPoolExecutor(max_workers=4) as executor:
        futures = []
        for course in course_list:
            url = url_data.format(course['id'])
            futures.append(executor.submit(download, url, course))
        for future in tqdm(futures, total=len(futures)):
            course = future.args[1]
            print('下载完成: {}'.format(
                course['course']['header']['title']))
            future.result()


download_all(json_data)
print('所有文件下载完成.')


json文件:https://api.smmdb.net/courses2?limit=120&skip=0 复制页面数据保存为smmdb.json 和这个py文件放在同一目录下 亲测可下载
kissfox 发表于 2023-6-14 13:04
davidiao 发表于 2023-6-14 13:09
m0216 发表于 2023-6-14 13:26
厉害   感谢楼主   有时间试试
雨之幽 发表于 2023-6-14 14:56
膜拜大佬
foggie 发表于 2023-6-14 15:35
厉害   感谢楼主   有时间试试这个游戏
darksetyaer 发表于 2023-6-14 15:45
拿自己博客测试一下
额微粒波地 发表于 2023-6-14 15:59
额微粒波地 发表于 2023-6-14 15:52
[mw_shl_code=python,true]# 吾爱破解 - 额微粒波地
# pip install requests
# pip install json

20230614155835.png
efujin 发表于 2023-6-14 16:50
不懂就问,smmdb.json的数据怎么获得的
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-5 18:41

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表