【发布时间】:2023-03-12 16:50:02
【问题描述】:
我正在使用 BeautifulSoup4 从 Spotify 图表中进行一些抓取。
我已经启动并运行了几个星期的代码。但是今天突然开始失败了。它开始为所有条目提供 NaN 值...
我相信问题出在 html 解析页面上。生成的 html 代码与原始网页 html 不同。
我尝试过使用“html.parses”、“lxml”和“html5lib”。我还更新了 BeautifulSoup 和所有解析器的包。但是什么都没有
可能是什么问题? 我不知道问题的根源是什么。昨天我的 Windows 10 更新了,可能与此有关吗?
下面是重要的代码部分:
from bs4 import BeautifulSoup as bs
import requests
u = 'https://spotifycharts.com/regional/us/daily/2021-04-18'
x = requests.get(u)
a = bs(x.content,'html.parser')
tracks = a.find_all('td',class_='chart-table-position')
tracks 总是 none,因为它不存在于 'a' 中。但它应该...因为它存在于网页html中并且它在几天前就存在...
提前感谢您的帮助。
【问题讨论】:
标签: python html parsing beautifulsoup spotify