The website limits the number of requests per second, so you need to include certain request headers or put a delay in your script (the first option is the fastest and probably the most reliable of the two).
Header Method:
''' add under team_id = 1610612737 ''' HEADERS = {'user-agent': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5)' 'AppleWebKit/537.36 (KHTML, like Gecko)' 'Chrome/45.0.2454.101 Safari/537.36'), 'referer': 'http://stats.nba.com/scores/'}
Then add this to your get answer:
response = requests.get(url, headers=HEADERS)
* You do not need to delay your script at all if you use this method.
Delay Method:
import time time.sleep(10)
Strike> It seems like skipping or skipping using a delay, so I would not recommend using it if absolutely necessary.
source share