网易云热门歌曲歌单爬虫

编程入门 行业动态 更新时间:2024-10-26 14:29:02

网易云热门歌曲歌单<a href=https://www.elefans.com/category/jswz/34/1770264.html style=爬虫"/>

网易云热门歌曲歌单爬虫

大佬绕路 一个初学者发表下见解。。。。



运行时找了半天的源码 没发现歌曲名字。。。。。

最后终于找到了:


然后利用正则表达式:



看了下大佬的代码:=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


更多推荐

网易云热门歌曲歌单爬虫

本文发布于:2024-02-25 20:10:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1700154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:爬虫   网易   热门歌曲

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!