Python BS4返回[],而不是想要的HTML标记

Python BS4返回[],而不是想要的HTML标记,python,html,parsing,beautifulsoup,Python,Html,Parsing,Beautifulsoup,我想解析给定的网站并刮表。在我看来,代码是正确的。python和web解析的新功能 import requests from bs4 import BeautifulSoup response = requests.get('https://delhifightscorona.in/') doc = BeautifulSoup(response.text, 'lxml-xml') cases = doc.find_all('div', {"class": "cel

我想解析给定的网站并刮表。在我看来,代码是正确的。python和web解析的新功能

import requests
from bs4 import BeautifulSoup
response = requests.get('https://delhifightscorona.in/')
doc = BeautifulSoup(response.text, 'lxml-xml')

cases = doc.find_all('div', {"class": "cell"})

print(cases)
这样做会有回报


[]

更改您的解析器和类,您就拥有了它

import requests
from bs4 import BeautifulSoup

soup = BeautifulSoup(requests.get('https://delhifightscorona.in/').text, 'html.parser').find('div', {"class": "grid-x grid-padding-x small-up-2"})

print(soup.find("h3").getText())
输出:

423,831

您可以选择仅打印案例或带有日期的总统计数据

import requests
from bs4 import BeautifulSoup
response = requests.get('https://delhifightscorona.in/')
doc = BeautifulSoup(response.text, 'html.parser')
stats = doc.find('div', {"class": "cell medium-5"})
print(stats.text)                 #Print the whole block with dates and the figures
cases = stats.find('h3')
print(cases.text)         #Print the cases only

你到底想要什么信息?页面上没有名为
cell
div
。感谢您的回复!我想打印箱子的总数。我想按类解析,因为我是新手,所以犯了个错误谢谢!!这正是我想要的。我们需要等待至少2分钟,直到我们可以标记出正确的答案