首页 > 解决方案 > 无法从 url 中选择表

问题描述

我无法从指定的 URL 中选择一个表(或实际上任何东西)。我用find_all了方法无济于事。网页上有多个由<h3>标签分隔的表格(下图是带有<h3>“基本”标签的表格)。

在此处输入图像描述

在此处输入图像描述

import requests
from bs4 import BeautifulSoup


res = requests.get('Example_URL')
soup = BeautifulSoup(res.text,'html.parser')
table = soup.find_all('table')[0]
print(table)

我希望能够选择表格,然后将内容打印到控制台上。但print(table)回报IndexError: list index out of range

标签: web-scrapingbeautifulsoup

解决方案


推荐阅读