我是美容小组的新手。我试图从ESPN Fantasy Basketball Standings中获取“Season Stats”表,但并不是返回所有行。经过一番研究,我认为这可能是一个问题html.parser,所以我用了lxml。我得到了同样的结果。如果有人能告诉我如何得到所有球队的名字,我会很感激的。在
我的代码:from bs4 import BeautifulSoup
from urllib.request import urlopen
soup = BeautifulSoup(urlopen("http://games.espn.com/fba/standings?leagueId=20960&seasonId=2017"),'html.parser')
tableStats = soup.find("table", {"class" : "tableBody"})
for row in tableStats.findAll('tr')[2:]:
col = row.findAll('td')
try:
name = col[0].a.string.strip()
print(name)
except Exception as e:
print(str(e))
输出(如您所见,仅显示几个团队名称):
Le Tuc Grizzlies
Peyton Ravens
Heaven Vultures
Versailles Golden Bears
Baltimore Corto's
La Murette Scavengers
XO Gayfishes