爬虫"/>
网易云热门歌曲歌单爬虫
大佬绕路 一个初学者发表下见解。。。。
运行时找了半天的源码 没发现歌曲名字。。。。。
最后终于找到了:
然后利用正则表达式:
看了下大佬的代码:=created
源码来啦:
import urllib.request
import re
def get_hotsongs_html():
url = '=316608987'
req = urllib.request.urlopen(url).read().decode('utf-8')
return (req)
def get_ID_Name():
s1 = "<a\shref=..song.id=\d{1,20}..>.+?<.a>"#r'<ul class="f-hide"><li><a href="/song\?id=\d*?">.*</a></li></ul>'#<ul class="f-hide"><li><a
# href="/song?id=186016">晴天</a></li>
result = repile(s1).findall(get_hotsongs_html())
return result
get_hotsongs_html()
s2=get_ID_Name()
num = 1
for data in s2:
print(str(num) + " " +data)
num += 1
更多推荐
网易云热门歌曲歌单爬虫
发布评论