当前位置:首页 > 资源 > 视频教程 >

python爬虫批量爬取喜马拉雅音频
栏目分类:视频教程   发布日期:2018-07-20   浏览次数:

coding = utf-8 import requests import json headers = {User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 } url = input(第一页网址:) url = url.replace(pageNum=1,pag
 
coding = "utf-8"
 
import requests
import json
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
}
 
url = input("第一页网址:")
url = url.replace('pageNum=1','pageNum={}')
page = int(input("页数:"))
 
start_url = url
new_url = []
for i in range(page):
url = start_url.format(i+1)
new_url.append(url)
for j in range(page):
r = requests.get(new_url[j],headers=headers)
ret = r.content.decode()
result = json.loads(ret)
temp = result["data"]["tracksAudioPlay"]
for i in temp:
list = {}
list['src'] = i['src']
list['name'] = i['trackName']
all_list = []
all_list.append(list)
for j in all_list:
with open('test/{}.m4a'.format(j['name']),'ab') as f:
n = requests.get(j['src'],headers=headers)
nation = n.content
f.write(nation)




 

相关热词: python

上一篇:各种教程合集
下一篇:没有了
这些是最新的
热门排行
©Copyright sem竞价员(www.semtor.com)版权所有   鄂ICP备17021581号   关于我们 | 广告合作 | 版权声明 | 意见反馈 | 联系方式 | 原创投稿 | 网站地图 |
SEM竞价 SEM教程 SEM资讯 资源