Oct-28-2017, 08:38 PM
Hi guys-New Python user here. I enjoy working with basketball statistics and have realized I need to figure out a more efficient way to scrape data from NBA.com. I found this script on the internet and have managed to (I think) get pretty close it working, but when I open Powershell and type "python NBA2.py" (file name) I get no response. Powershell stays open but doesn't give any feedback or let me type anymore. FYI I'm using Windows 10 and Python 3.6
import requests
import csv
url = "http://stats.nba.com/stats/leaguedashplayerstats?DateFrom=&DateTo=&GameScope=&GameSegment=&LastNGames=15&LeagueID=00&Location=&MeasureType=Advanced&Month=0&OpponentTeamID=0&Outcome=&PaceAdjust=N&PerMode=Totals&Period=0&PlayerExperience=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2015-16&SeasonSegment=&SeasonType=Regular+Season&StarterBench=&VsConference=&VsDivision="
data = requests.get(url)
entries = data.json()
with open('output.csv', 'wb') as f_output:
csv_output = csv.writer(f_output)
csv_output.writerow(entries['resultSets'][0]['headers'])
csv_output.writerows(entries['resultSets'][0]['rowSet'])If anyone could provide some info on why this isn't working or point me toward a website that can help it would be greatly appreciated. I've spent hours troubleshooting and can't seem to pinpoint where the problem is.

). The url in my script takes me directly to a web page with the data separated by commas. From there I just need get it into a format that I can analyze within Excel. I feel like the script I posted should do that, but I must be missing something.