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

网易云热门歌曲歌单爬虫

网易云热门歌曲歌单爬虫

网易云热门歌曲歌单爬虫

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

最后终于找到了:网易云热门歌曲歌单爬虫

网易云热门歌曲歌单爬虫

然后利用正则表达式:

网易云热门歌曲歌单爬虫


看了下大佬的代码:https://www.zhihu.com/question/41505181?sort=created

网易云热门歌曲歌单爬虫

网易云热门歌曲歌单爬虫


网易云热门歌曲歌单爬虫


源码来啦:

import urllib.request
import re

def get_hotsongs_html():
    url = 'http://music.163.com/playlist?id=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 = re.compile(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


相关文章:

  • 2022-01-16
  • 2022-12-23
  • 2021-08-27
  • 2021-06-13
  • 2021-05-13
  • 2022-01-22
  • 2021-07-29
  • 2021-05-31
猜你喜欢
  • 2022-01-01
  • 2022-01-01
  • 2021-08-10
  • 2021-07-12
  • 2021-08-25
  • 2021-11-23
  • 2021-09-04
相关资源
相似解决方案