从basketball-reference.com中收集nba球员数据,并且很少有方法对数据进行排序
stats-scraper的Python项目详细描述
一个简单的cli python web scraper,可以刮除nba 来自basketball-reference.org和 允许球员按分数、篮板和 协助和展示。
安装
将.py文件保存在stats scraper下,并用python3运行它。有关任何模块要求,请参见requirements.txt并使用pip安装它们
或者使用pip直接安装stats_scraper
pip install stats_scraper
用法
代码摘录自py
from stats_scraper.scraper import Scraper scraper = Scraper() result = scraper.find_player_by_name("Ivica Zubac") print("Printing result\n") for p in result: print(p) sorted_points = scraper.sort_by_points("SG") print("========Printing top scorers========\n") for scores in sorted_points: print(scores[0], scores[1]) sorted_assists = scraper.sort_by_assists("PF") print("\n\n\n=========Printing top 10 assisters========\n") count = 0 for assists in sorted_assists: if(count >= 10): break print(assists[0], assists[1]) count += 1 sorted_rebounds = scraper.sort_by_rebounds("PG", "SG") print("\n\n\n=========Printing top 20 rebounders========\n") count = 0 for rebounds in sorted_rebounds: if(count >= 20): break print(rebounds[0], rebounds[1]) count += 1
确认
感谢奥斯卡·桑切斯的文章“网上搜刮NBA数据” 对于部分刮码