?import requests
import re
url = "http://www.ysxs8.vip/downlist/16697.html"
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0'}
k = "http://ysting.ysxs8.vip:81/网络玄幻/吞噬星空(边江,刘思岑)/"
res = requests.get(url, headers=header)
res.encoding = res.apparent_encoding
html = res.text
# print(html)
# tmp='\xbe\xfc\xca\xc2'
# print(tmp.decode('gbk').encode('utf-8'))
# tmp='\xbe\xfc\xca\xc2'
# print tmp.decode('gbk').encode('utf-8')
patterm = """<a title='(.*?)' href='(.*?)' target="_self">(.*?)</a>"""
match = re.findall(patterm, html)
# print(match)
# w = int(input("从第几集开始下?"))
# g = int(input("从第几集开始下?"))
# d = 0
w = 0
for i in match:
if w == 0:
w = 1
continue
mp3_url = k + i[2] + ".m4a"
print(mp3_url)
print(f'--------------正在下载:{i[2]}---------------')
with open(f"吞噬星空2/{i[2]}.mp3", mode="wb") as f:
# 发送网络请求
z_resp = requests.get(url=mp3_url, headers=header)
# 音频
music = z_resp.content
# 写入文件中
f.write(music)
print('**************下载完成***************\n')
# print(html)
那帮我看看为什么这个程序下载的音频无法播放(我自己都快爬好了) |