Python 3.x 无法提取表数据

Python 3.x 无法提取表数据,python-3.x,web-scraping,beautifulsoup,Python 3.x,Web Scraping,Beautifulsoup,这是我的代码,即使在提取HTML内容之后,我也无法提取表数据。我做错了什么?表中的数据存储在HTML注释中()。要解析它,可以使用以下示例: import requests from bs4 import BeautifulSoup URL = 'https://www.mohfw.gov.in/' page = requests.get(URL) soup = BeautifulSoup(page.content, 'html.parser') table = soup.find('table

这是我的代码,即使在提取HTML内容之后,我也无法提取表数据。我做错了什么?

表中的数据存储在HTML注释中(
)。要解析它,可以使用以下示例:

import requests
from bs4 import BeautifulSoup
URL = 'https://www.mohfw.gov.in/'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
table = soup.find('table')
table_body = table.find_all('tr')
print(table_body)

表中的数据存储在HTML注释(
)中。要解析它,可以使用以下示例:

import requests
from bs4 import BeautifulSoup
URL = 'https://www.mohfw.gov.in/'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
table = soup.find('table')
table_body = table.find_all('tr')
print(table_body)

非常感谢,这太棒了!非常感谢,这太棒了!
1    Andaman and Nicobar Islands                                 47        133       0         
2    Andhra Pradesh                                              18159     19393     492       
3    Arunachal Pradesh                                           387       153       3         
4    Assam                                                       6818      12888     48        
5    Bihar                                                       7549      14018     197       
6    Chandigarh                                                  164       476       11        
7    Chhattisgarh                                                1260      3451      21        
8    Dadra and Nagar Haveli and Daman and Diu                    179       371       2         
9    Delhi                                                       17407     97693     3545      
10   Goa                                                         1272      1817      19        
11   Gujarat                                                     11289     32103     2089      
12   Haryana                                                     5495      18185     322       
13   Himachal Pradesh                                            382       984       11        
14   Jammu and Kashmir                                           5488      6446      222       
15   Jharkhand                                                   2069      2513      42        
16   Karnataka                                                   30661     19729     1032      
17   Kerala                                                      5376      4862      37        
18   Ladakh                                                      176       970       1         
19   Madhya Pradesh                                              5562      14127     689       
20   Maharashtra                                                 114947    158140    11194     
21   Manipur                                                     635       1129      0         
22   Meghalaya                                                   309       66        2         
23   Mizoram                                                     112       160       0         
24   Nagaland                                                    525       391       0         
25   Odisha                                                      4436      10877     79        
26   Puducherry                                                  774       947       22        
27   Punjab                                                      2587      6277      230       
28   Rajasthan                                                   6666      19970     538       
29   Sikkim                                                      155       88        0         
30   Tamil Nadu                                                  46717     107416    2236      
31   Telangana                                                   13327     27295     396       
32   Tripura                                                     676       1604      3         
33   Uttarakhand                                                 937       2995      50        
34   Uttar Pradesh                                               15720     26675     1046      
35   West Bengal                                                 13679     21415     1023      
     Cases being reassigned to states                            531                           
     Total#                                                      342473    635757    25602