我是美容小組的新手。我試圖從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