Football_CLI.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:Football-CLI 作者: jctissier 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号