• 有声小说


    import requests

    # 定义页数
    page = 1
    # 书籍信息
    start_url = 'https://www.ximalaya.com/revision/category/queryCategoryPageAlbums?category=youshengshu&subcategory=yanqing&meta=&sort=0&page={}&perPage=30'

    for page in range(30):
    url = start_url.format(page)

    headers = {

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36'
    }
    response = requests.get(url, headers=headers).json()
    data = response['data']['albums']
    for sou in data:
    albumId = sou['albumId']

    book_url = 'https://www.ximalaya.com/revision/play/v1/show?id={}&num=1&sort=-1&size=30&ptype=0'.format(albumId)
    response_book = requests.get(book_url, headers=headers).json()
    book_list = response_book['data']['tracksAudioPlay']
    for bl in book_list:
    book_title = bl['trackName']
    book_id = bl['trackId']

    audio_url = 'https://www.ximalaya.com/revision/play/v1/audio?id={}&ptype=1'.format(book_id)
    response_audio = requests.get(audio_url, headers=headers).json()
    m4a_audio = response_audio['data']['src']
    if m4a_audio is not None:
    request_m4a_audio = requests.get(m4a_audio, headers=headers).content
    # print(book_title)
    # print(request_m4a_audio)

    with open('有声电子书/{}.mp4'.format(book_title), 'wb') as f:
    f.write(request_m4a_audio)
    f.close()
  • 相关阅读:
    ACM Dance Recital(dfs+剪枝)
    矩阵快速幂
    分页实现复选框的选中状态
    MemCached 和redis的区别
    调用存储过程传值
    实现js中的时间格式中的T
    实现下载完成
    模态框实现功能后刷新父类页面
    JSON.parse()、JSON.stringify()和eval()的作用
    全选反选珍藏班版
  • 原文地址:https://www.cnblogs.com/LQ970811/p/11854764.html
Copyright © 2020-2023  润新知