130******98
deepin
2017-01-04 23:39 python2可以吗
Reply Like 0 View the author
https://bbs.deepin.org/post/133744
python2可以吗
https://bbs.deepin.org/post/133744
就我这点蹩脚的python知识竟然看懂了。
这是网页上的接口吧?整理个全部的接口,楼主你就可以开始写界面了 ...
https://bbs.deepin.org/post/133744
有现成的网易云音乐没必要写界面倒是有写一部份界面不过后面就没动力写了,放这个出来,就是看看能不能多 ...
Popular Ranking
ChangePopular Events
More
源代码:
------------------------------------------------------------------------------------------优雅的分割线--------------------------------------------------------------------------------------
import urllib.parse
import urllib.request
import json
#获取源代码
def get_html(word):
url = "http://s.music.163.com/search/get/?type=1&s="+urllib.parse.quote(word)+"&limit=10"
html = urllib.request.urlopen(url).read().decode("utf-8")
return html
#解析数据
def parse(html):
dc = json.loads(html)
c = 0
list_picurl = []
list_audio = []
list_name = []
list_audioname = []
for i in dc["result"]["songs"]:
print(c)
print("正在解析第"+str(c+1)+"首歌曲信息")
list_audioname.append(dc["result"]["songs"][c]["album"]["name"])
list_picurl.append(dc["result"]["songs"][c]["album"]["picUrl"])
list_audio.append(dc["result"]["songs"][c]["audio"])
list_name.append(dc["result"]["songs"][c]["artists"][0]["name"])
print("歌 名:"+list_name[c])
print("歌 手:"+list_audioname[c])
print("音乐地址:"+list_audio[c])
print("封面图片:"+list_picurl[c])
c += 1
#执行上面定义的函数
parse(get_html(input("请输入你要搜索的歌曲:")))
------------------------------------------------------------------------------------------优雅的分割线--------------------------------------------------------------------------------------
对就是这样,把上面的代码复制下来,保存为 .py 格式就好了,代码是用Python3写的,所以请用python3运行。
分享是一种美德,一起去,糟蹋PYTHON吧,哦不,一起去学习Python吧!