【发布时间】:2017-04-01 17:17:42
【问题描述】:
我正在尝试从网站中提取特定的表值 (http://www.forexfactory.com/calendar.php?day=nov18.2016) 使用 Python BeautifulSoup
到目前为止的代码:
from bs4 import BeautifulSoup
from urllib.request import urlopen
content = urlopen("http://www.forexfactory.com/calendar.php?day=nov18.2016").read()
soup = BeautifulSoup(content, 'html.parser')
tables = soup.findAll("table")
for table in tables:
if table.findParent("table") is None:
print(table)
我可以打印所有多个表及其内容,但是如何获取名为“calendar__table”的特定表并通过它进行迭代以获取每一行及其值?
【问题讨论】:
标签: python beautifulsoup lxml