Portfolio / Sports stats scraper
Sports stats scraper
Collect a whole season of game logs in one run, then settle the argument: compare any two players on points, rebounds, assists or 3-point shooting, and see who’s hot right now.
Press Scrape. I’ll collect the whole season while you stretch.
Meet Jamal, who runs a fantasy basketball league with his friends.
Every week the group chat argues about who to start and who to trade. Jamal copies numbers from stats pages into a spreadsheet by hand, player by player, and by the time he’s done the next game has already been played.
Example scenario. The league, players and stats shown are sample data.
Before
- Copying stats from web pages by hand
- Twenty minutes per player, every week
- No easy way to see who’s on a hot streak
- Arguments settled by whoever talks loudest
After
- A whole season collected in one run
- Rolling averages that show real form
- Any two players compared in a click
- Arguments settled by data
Try it yourself
Points
Season averages and current form
| Player | Team | Pts | Reb | Ast | 3P% | Last 5 | Form |
|---|
League leaders
A browser simulation using a sample league with fictional players. The real tool is a Python script that collects data from public stats pages.
What this could be worth to you
Copying stats by hand is slow. The same scraper idea works for prices, listings and competitors.
Example numbers to start you off. Move the sliders to match your business. These are estimates, not a guarantee or financial advice; your results depend on your situation.
The problem
Stats sites show one player at a time, so building comparisons or tracking streaks means copying numbers by hand, which is slow and goes stale fast.
The solution
A Python script that visits each player’s game-log page, pulls the numbers into one clean table, and fixes gaps like missing minutes. From there, rolling averages, hot and cold streaks, and head-to-head comparisons are instant.
How it's built
- CollectVisit each player’s game-log page.
- ParsePull the table of games into rows.
- CleanFix missing values and consistent column names.
- AnalyzeRolling averages, last-5 form, league leaders.
- ShareA dashboard or a weekly email for the group.
A simplified version of the scraper:
import requests, pandas as pd
from bs4 import BeautifulSoup
rows = []
for player in players:
html = requests.get(f"https://stats.example.com/players/{player}/gamelog", timeout=10).text
table = BeautifulSoup(html, "html.parser").select_one("table.gamelog")
df = pd.read_html(str(table))[0]
df["Player"] = player
rows.append(df)
games = pd.concat(rows).fillna({"MIN": 0})
games["PTS_5g"] = games.groupby("Player")["PTS"].transform(lambda s: s.rolling(5, 1).mean())
games.to_csv("player_games.csv", index=False)
What it makes possible
- A season of data collected in minutes
- Real form, not just season averages
- The same approach works for prices, reviews or competitor data
Skills shown
More to try
Need data that’s stuck on web pages?
Prices, listings, stats or reviews: I can collect it automatically (from sites that allow it).
Starting prices are for smaller projects. Bigger or more complex jobs are priced by scope: how much there is and how long it takes.