Тёмный

API Web Scraping NBA Stats in Python | NBA Data Analytics Project (part 1/2) 

Alex Sington
Подписаться 1,8 тыс.
Просмотров 41 тыс.
50% 1

Watch Part 2: • Analyzing NBA Data in ...
Contact me:
alex.sington@gmail.com
/ alex-sington-b7751a181
In this video, I scrape data from nba.com/stats for analysis in the second part of my project. This video will teach you how to find NBA APIs, and scrape data on a large scale with the Python requests package.

Опубликовано:

 

21 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 43   
@scottgower
@scottgower Год назад
This was awesome! I’ve been wanting to scrape sports data in a loop like this for a while. Thanks!
@tomkmb4120
@tomkmb4120 Год назад
Thanks a lot for taking the time to make this video man, I'm a huge sports fan who's been self learning Python for the last 4 months or so. Just getting into looking at Jupyter, Numpy and Pandas, so these videos are a great resource for me. Why don't NBA stats want you scraping from them? I don't understand what the issue is, is it just that large numbers of requests put pressure on their servers? Will move on to part 2 now!
@alexsington
@alexsington Год назад
That's great to hear!! To answer your question: I think (and this is just my basic understanding) websites try to prevent scraping so that bots can't access all the data with malicious intent (e.g., selling the data). So the goal of adding headers is to appear less bot-like (by changing the user agent).
@tomkmb4120
@tomkmb4120 Год назад
@@alexsington Yeah that makes sense from your end. Web Scraping is still so new to me but I've heard it referred to as 'ethically dubious' and I just cannot understand outside of putting the strain on the server with multiple requests simultaneously why it would be an issue for you to take a copy of data they've made available publicly. Do you plan on doing any similar videos for any other sports?
@kevinle4977
@kevinle4977 Год назад
Would that data that is locked out be available on the nba_api?
@joelngige5776
@joelngige5776 Год назад
Nice video on websrapping. Love it!!!
@chels1023
@chels1023 10 месяцев назад
Great video, really easy to follow along.
@orlandodeabreu9167
@orlandodeabreu9167 Год назад
Excellent video content and beautiful scrap data.
@RaiSantosDev
@RaiSantosDev 4 месяца назад
So cool! Thanks for sharing
@rustinshamloo5557
@rustinshamloo5557 Год назад
Good stuff, Fight On bro!
@derrickbecker9856
@derrickbecker9856 8 месяцев назад
Can you look at FT differential vs W/L and look at statistical significant correlations of this happening to large markets over small markets ?
@rogerandrade3273
@rogerandrade3273 10 месяцев назад
Nice fella 💪💪
@favourphilicvictor1059
@favourphilicvictor1059 11 месяцев назад
Thank you for this tutorial
@msports4life35
@msports4life35 11 месяцев назад
Great video, thanks for the info! I was trying to recreate this but it seems like they've locked the page down quite a bit, any time I pull any of the URLs it just continuously loads and never renders. Any suggestions/tips to pull this data consistently?
@hienvo217
@hienvo217 10 месяцев назад
having the same problem here!
@jonathanhiggins2017
@jonathanhiggins2017 10 месяцев назад
Any luck with being able to pull the data?
@frankweber7055
@frankweber7055 8 месяцев назад
Did you work this out?
@phantasm3207
@phantasm3207 3 месяца назад
They have an option to share the data which allows you to download it... no need to scrap 🎉
@logic0057
@logic0057 Год назад
Awesome!
@tanner9956
@tanner9956 5 месяцев назад
Guys does anyone watching this actually have a winning sports betting model is it possible or are the casinos already on it
@aalapdesai2725
@aalapdesai2725 5 месяцев назад
Is there a diff technique to get teams data because whenever I try this technique to get teams data the server connections get abot=rted without response if there is any other way pls do tell me
@Fabo730
@Fabo730 Год назад
At 7:30 when you say that data used to be available but not anymore... is there really no way to get it? For example if I wanna pull team's offensive and defensive ratings (which has the same problem as those shooting stats), is the only way to get it is through scraping the hmtl source?
@alexsington
@alexsington Год назад
No, you can definitely scrape that too, but you just can't use this simple API method. I'd recommend trying something like beautiful soup.
@ramfanintexas
@ramfanintexas Год назад
what exactly did you do to solve the final error? I got the same error. removed headers=headers but I'm still getting the same error.
@alexsington
@alexsington Год назад
If you are trying to scrape a page where the API is not available, then that's the problem. If not, then, to be completely honest, I don't have a good answer for you. I tried running the code with and without headers. It just took a few tries before it ran all the way through without getting blocked, and I don't know why one try failed while another try succeeded.
@ahmadkurniawan6984
@ahmadkurniawan6984 Год назад
i keep the headers=headers, and change the np.random.uniform() to 1 sec , and keep rerun until it done "sorry my english sucks hopefully it helped you"
@nishchay89
@nishchay89 Год назад
@@ahmadkurniawan6984 not working for me bro, can you help?
@ahmadkurniawan6984
@ahmadkurniawan6984 Год назад
@@nishchay89 thats the only thing i did bro , just keep doing it til it succeeds, give me your email, i can send you my notebook if you want
@ahmadkurniawan6984
@ahmadkurniawan6984 Год назад
@@nishchay89 done check ur email
@aadarshb.k.6883
@aadarshb.k.6883 Месяц назад
Where is second part.
@hahathatsucks8019
@hahathatsucks8019 6 месяцев назад
how did you get your data extracted into Excel? I compress all seasons from 2012 - 2021 & then input "data = pd.read_excel('nba_player_data.xlsx')"
@jacksondavies8695
@jacksondavies8695 6 месяцев назад
Were you able to scrape all the data?
@jacksondavies8695
@jacksondavies8695 6 месяцев назад
I keep running it over and over again but I’m getting a KeyError: ‘resultSet’ after it attempts to scrape the data
@thegod1320
@thegod1320 4 месяца назад
@@jacksondavies8695 me to did you ever fix this?
@NGSRumble
@NGSRumble 3 месяца назад
@@jacksondavies8695 I was getting the same error, turns out that I didn't enter the url correctly in the for loop. Make sure it matches the video!
@dizzylu4767
@dizzylu4767 Месяц назад
@@NGSRumble Yo I did the exact same thing but I get the same keyError
@nishchay89
@nishchay89 Год назад
I am not able to scrape data. It crashes when fetching data for 2012-13 playoffs season. Can you help? Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages equests\models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Nishchay\AppData\Local\Temp\ipykernel_12448\3071084054.py", line 29, in r = requests.get(url = api_url).json() File "C:\ProgramData\Anaconda3\lib\site-packages equests\models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@aditya0333
@aditya0333 10 месяцев назад
could you solve this?
@jellyfish1388
@jellyfish1388 Год назад
How to earn money with this stats ?
@alexsington
@alexsington Год назад
What do you mean by that?
@jellyfish1388
@jellyfish1388 Год назад
@@alexsington bying this data or maybe use this for gambling after analyse data
Далее
HA-HA-HA 👊  #countryball
00:15
Просмотров 1,9 млн
The NBA Data Scientist
8:06
Просмотров 550 тыс.
Always Check for the Hidden API when Web Scraping
11:50