小编t0m*_*mas的帖子

网页抓取问题

我正在尝试在PyCharm 中编写一个程序(我以前没有使用过这个 IDE,但我认为这不是问题)我在从某个类中收集数据时遇到了麻烦,“react-contextmenu-wrapper ”

我想编写一个脚本来解析 Spotify 上的网页并使用数据创建一个 CSV 文件,我一直在关注 YouTube 上的教程,但我一定在某个地方出错了。

这是我的代码:

from urllib.request import urlopen as Req
from bs4 import BeautifulSoup as soup

my_url = "https://open.spotify.com/genre/NMF-PopularNewReleases"

#grabs the contense of the page
Client = Req(my_url)

#reads the contense of the page
html = Client.read()

#outputs the page
Client.close()

page = soup(html, "html.parser")

#grabs each playlist
playlists = page.findAll("div",{"class":"react-contextmenu-wrapper"})

print(len(playlists))
Run Code Online (Sandbox Code Playgroud)

但是终端输出一个空列表,我知道这个类存在。当我检查页面的元素时,我可以查看它。

html python web-scraping

2
推荐指数
1
解决办法
130
查看次数

标签 统计

html ×1

python ×1

web-scraping ×1