in:key word
out:歌词,热评,热评用户的头像下载
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100import requests import json import os from urllib.request import urlretrieve def GetConment(kw): url = 'http://120.79.36.48/search?keywords=%20'+kw resp = requests.get(url) resp.encoding = 'utf8' hjson = resp.json() # if not 'songs' in hjson: # return 'No Lyric' songs = [] for x in range(0,len(hjson['result']['songs'])): # print(hjson['result']['songs'][x]['id']) songs.append(hjson['result']['songs'][x]['id']) # print(songs) if len(songs)==0: return 'No Songs' cnt = 0 for s in songs: commenturl = 'http://120.79.36.48/comment/music?id='+str(s)+'&limit=1' # print(liricsurl) r = requests.get(commenturl) r.encoding = 'utf8' json = r.json() comment = json['hotComments'] for i in range(0,len(comment)-1): print('『'+str(cnt)+'』'+comment[i]['content']) cnt = cnt +1 print(comment[i]['user']['avatarUrl']) # cont = cont + comment[i]['content'] def DawnloadHeader(kw): url = 'http://120.79.36.48/search?keywords=%20'+kw resp = requests.get(url) resp.encoding = 'utf8' hjson = resp.json() # if not 'songs' in hjson: # return 'No Lyric' songs = [] for x in range(0,len(hjson['result']['songs'])): # print(hjson['result']['songs'][x]['id']) songs.append(hjson['result']['songs'][x]['id']) # print(songs) if len(songs)==0: return 'No Songs' cnt = 0 dirname = kw+'Header' if not os.path.exists(dirname): os.makedirs(dirname) for s in songs: commenturl = 'http://120.79.36.48/comment/music?id='+str(s)+'&limit=1' # print(liricsurl) r = requests.get(commenturl) r.encoding = 'utf8' json = r.json() comment = json['hotComments'] for i in range(0,len(comment)-1): print('正在下载:'+comment[i]['user']['avatarUrl']) filename=os.path.join(dirname,str(cnt)+comment[i]['user']['nickname']+'.jpg') with open(filename,'w') as f: urlretrieve(comment[i]['user']['avatarUrl'],filename) cnt = cnt +1 print('已下载完!') def Getlirics(kw,cnt): url = 'http://120.79.36.48/search?keywords=%20'+kw resp = requests.get(url) resp.encoding = 'utf8' hjson = resp.json() # if not 'songs' in hjson: # return 'No Lyric' songs = [] for x in range(0,cnt): # print(hjson['result']['songs'][x]['id']) songs.append(hjson['result']['songs'][x]['id']) # print(songs) if len(songs)==0: return 'No Lyric' lir = '' for s in songs: liricsurl = 'http://120.79.36.48/lyric?id='+str(s) # print(liricsurl) r = requests.get(liricsurl) r.encoding = 'utf8' json = r.json() lyric = json['lrc']['lyric'] lyricUser = 'No User' if 'lyricUser' in json: lyricUser = json['lyricUser']['nickname'] # print('['+lyricUser+']n'+lyric) lir = lir + '『'+lyricUser+'』n'+lyric+'n' if lir == '': return '' return lir DawnloadHeader('你的名字')
最后
以上就是怡然铃铛最近收集整理的关于Python抓取网易云 歌词,热评,热评用户的头像的全部内容,更多相关Python抓取网易云内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复