1. 程式人生 > >python下載想聽的有聲書,讓喜馬拉雅收費,我是程式設計師!

python下載想聽的有聲書,讓喜馬拉雅收費,我是程式設計師!

from urllib import parse,request
import urllib

header_dict = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'}
for i in range(1328,3000):
    url="https://ting55.com/book/9580-"+str(i)
    req = request.Request(url=url, headers=header_dict)
    res = request.urlopen(req)
    res 
= res.read() body=str(res,encoding='utf-8') startStr='(function(){var a={m4a:"' start=body.find(startStr) end=body.find('"};ting55_play("m4a",') url=body[start+len(startStr):int(end)] LocalPath="D:/超品相師/"+str(i)+".m4a" print('正在下載第'+str(i)+"集...") urllib.request.urlretrieve(url,LocalPath)