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

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 44

  • @scottgower
    @scottgower Рік тому +3

    This was awesome! I’ve been wanting to scrape sports data in a loop like this for a while. Thanks!

  • @joelngige5776
    @joelngige5776 Рік тому

    Nice video on websrapping. Love it!!!

  • @tomkmb4120
    @tomkmb4120 2 роки тому +4

    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  2 роки тому +1

      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 2 роки тому

      @@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?

  • @Fabo730
    @Fabo730 Рік тому +1

    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.

  • @orlandodeabreu9167
    @orlandodeabreu9167 Рік тому

    Excellent video content and beautiful scrap data.

  • @chels1023
    @chels1023 Рік тому

    Great video, really easy to follow along.

  • @derrickbecker9856
    @derrickbecker9856 10 місяців тому

    Can you look at FT differential vs W/L and look at statistical significant correlations of this happening to large markets over small markets ?

  • @RaiSantosDev
    @RaiSantosDev 7 місяців тому

    So cool! Thanks for sharing

  • @overpoweredmeowmix
    @overpoweredmeowmix 22 дні тому

    I cant access the api anymore with the same methods, any idea if NBA locked its basic data too now?

  • @msports4life35
    @msports4life35 Рік тому +3

    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?

  • @rustinshamloo5557
    @rustinshamloo5557 2 роки тому

    Good stuff, Fight On bro!

  • @rogerandrade3273
    @rogerandrade3273 Рік тому +1

    Nice fella 💪💪

  • @aalapdesai2725
    @aalapdesai2725 8 місяців тому

    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

  • @favourphilicvictor1059
    @favourphilicvictor1059 Рік тому

    Thank you for this tutorial

  • @phantasm3207
    @phantasm3207 5 місяців тому

    They have an option to share the data which allows you to download it... no need to scrap 🎉

  • @ramfanintexas
    @ramfanintexas 2 роки тому +1

    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  2 роки тому

      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 2 роки тому

      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 Рік тому +1

      @@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 Рік тому +1

      @@nishchay89 done check ur email

  • @logic0057
    @logic0057 Рік тому

    Awesome!

  • @aadarshb.k.6883
    @aadarshb.k.6883 3 місяці тому

    Where is second part.

  • @hahathatsucks8019
    @hahathatsucks8019 8 місяців тому

    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 8 місяців тому

      Were you able to scrape all the data?

    • @jacksondavies8695
      @jacksondavies8695 8 місяців тому

      I keep running it over and over again but I’m getting a KeyError: ‘resultSet’ after it attempts to scrape the data

    • @thegod1320
      @thegod1320 7 місяців тому

      @@jacksondavies8695 me to did you ever fix this?

    • @NGSRumble
      @NGSRumble 6 місяців тому

      @@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 3 місяці тому

      @@NGSRumble Yo I did the exact same thing but I get the same keyError

  • @tanner9956
    @tanner9956 7 місяців тому

    Guys does anyone watching this actually have a winning sports betting model is it possible or are the casinos already on it

  • @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)

  • @jellyfish1388
    @jellyfish1388 2 роки тому

    How to earn money with this stats ?

    • @alexsington
      @alexsington  2 роки тому

      What do you mean by that?

    • @jellyfish1388
      @jellyfish1388 2 роки тому

      @@alexsington bying this data or maybe use this for gambling after analyse data