generate functionSat, 07 Jan 2023

a bot that scrapes for all player stats. Stats should include points per game(ppg), assists per game(apg), rebounds per game(rpg), steals per game(spg).

import requests from bs4 import BeautifulSoup import pandas as pd import numpy as np def nba_stats(): url = "" response = requests.get(url) soup = BeautifulSoup(response.content, "html.parser") table = soup.find("table", id="per_game_stats") stats = table.find("tbody") player_stats = [] for row in stats.findAll("tr"): player = row.find("th", {"data-stat": "player"}) ppg = row.find("td", {"data-stat": "pts_per_g"}) apg = row.find("td", {"data-stat": "ast_per_g"}) rpg = row.find("td", {"data-stat": "trb_per_g"}) spg = row.find("td", {"data-stat": "stl_per

Questions about programming?Chat with your personal AI assistant