def top_scorers(self, league_url, league_name):
cprint("\nRetrieving Top Scorers for " + league_name + "...", 'yellow')
cprint("Rank Player Team Goals", 'red', attrs=['bold', 'underline'])
r = requests.get(league_url)
soup = BeautifulSoup(r.content, "lxml")
try:
for x in range(0, 15):
player_name = soup.find_all("td", {"class": "player large-link"})[x].text
team_name = soup.find_all("td", {"class": "team large-link"})[x].text
goals_count = soup.find_all("td", {"class": "number goals"})[x].text
if x < 9:
topscorer = "{:<20}".format(player_name), space, "{:<15}".format(team_name), space, goals_count
cprint(" " + str(x + 1) + ". " + str("".join(topscorer)), 'blue')
elif 9 <= x:
topscorer = "{:<20}".format(player_name), space, "{:<15}".format(team_name), space, goals_count
cprint(" " + str(x + 1) + ". " + str("".join(topscorer)), 'blue')
except IndexError:
pass
# Scrapes subreddit in Reddit to display URLs to live streams (when available) based on user input
评论列表
文章目录