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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM