mp3手机怎么下载(批量下载“爱书音”有声小说mp3)

最近在听阿陈播的二号首长,非常过瘾,1~3部全听完了,发现后续还有高手过招。不过是在爱书音网页上。

mp3手机铃声下载


不过一共122集,于是想实现把这些的音频mp3都下载到手机上听。

分析了下 :

比如第18集,url是“https://www.ishuyin.com/player.php?mov_id=19248&look_id=18&player=down”

打开每集的页面,中间有个下载,href里面真好是mp3的下载地址:


但是事情没那么简单,通过查看网页源码发现:

这个href是加密的,是通过js动态算出来的。在页面中找找js,发现了加密算法:


也就是先通过*切割字符串,再将每个数字转换成字母。

通过以上分析,就有了思路:

全部代码:

import requests import json from bs4 import BeautifulSoup s = requests.Session() headers = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate, br", "Host": "www.ishuyin.com", "Referer": "https://www.ishuyin.com/show-19248.html", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" } def parse(url): ret = s.get(url=url, headers=headers) soup = BeautifulSoup(ret.content, "html.parser") d = soup.select("#urlDown")[0] h = d.attrs["href"].split("*") r = "".join([chr(int(x)) for x in h if x != ""]) return r def download(link, index): ss = requests.Session() ret = ss.get(link) with open("mp3/{}.mp3".format(index), 'wb') as file: file.write(ret.content) if __name__ == '__main__': for i in range(34, 123): url = "https://www.ishuyin.com/player.php?mov_id=19248&look_id={}&player=down".format(i) link = parse(url) download(link, i) print(u"第{}集下载完成".format(i))

效果:



源码:https://github.com/onelittlecoder/python/blob/master/cmd/multi-download-ishuyin-mp3.py

您可以还会对下面的文章感兴趣

最新评论

  1. 鹿岛
    鹿岛
    发布于:2022-04-27 05:29:26 回复TA
    *切割字符串,再将每个数字转换成字母。通过以上分析,就有了思路:全部代码:import requestsimport jsonfrom bs4 import BeautifulSoups = requests.Session()headers = { "Accept": "text
  1. 我怎么敢凶你
    我怎么敢凶你
    发布于:2022-04-27 05:21:45 回复TA
    nt(u"第{}集下载完成".format(i))效果:​​源码:https://github.com/onelittlecoder/python/blob/master/cmd/multi-download-ishuyin-mp3.py
  1. 少年痴货
    少年痴货
    发布于:2022-04-27 01:38:06 回复TA
    requests.Session() ret = ss.get(link) with open("mp3/{}.mp3".format(index), 'wb') as file: file.write(ret.content)if __name__
  1. 储菲进姣
    储菲进姣
    发布于:2022-04-27 01:19:46 回复TA
    抱抱我的宝贝
  1. 幸晴承善
    幸晴承善
    发布于:2022-04-27 01:19:46 回复TA
    做生意的最高境界是淡季不淡,旺季更旺。

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

使用微信扫描二维码后

点击右上角发送给好友