~\anaconda3\lib\site-packages\urllib3\util\retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
531 if read is False or not self._is_method_retryable(method):
--> 532 raise six.reraise(type(error), error, _stacktrace)
533 elif read is not None:
~\anaconda3\lib\site-packages\urllib3\packages\six.py in reraise(tp, value, tb)
769 raise value.with_traceback(tb)
--> 770 raise value
771 finally:
~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
698 # Make the request on the httplib connection object.
--> 699 httplib_response = self._make_request(
700 conn,
~\anaconda3\lib\site-packages\schedule__init__.py in run_pending(self)
98 runnable_jobs = (job for job in self.jobs if job.should_run)
99 for job in sorted(runnable_jobs):
--> 100 self._run_job(job)
101
102 def run_all(self, delay_seconds: int = 0) -> None:
~\anaconda3\lib\site-packages\schedule__init__.py in _run_job(self, job)
170
171 def _run_job(self, job: "Job") -> None:
--> 172 ret = job.run()
173 if isinstance(ret, CancelJob) or ret is CancelJob:
174 self.cancel_job(job)
~\anaconda3\lib\site-packages\schedule__init__.py in run(self)
659
660 logger.debug("Running job %s", self)
--> 661 ret = self.job_func()
662 self.last_run = datetime.datetime.now()
663 self._schedule_next_run()
~\AppData\Local\Temp/ipykernel_18104/3376019070.py in job(t)
469
470 #vs WESTERN CONFERENCE Off Stats
--> 471 statfind = leaguedashteamstats.LeagueDashTeamStats(season=SZN, measure_type_detailed_defense=('Opponent'),date_to_nullable=DTo, vs_conference_nullable=('West'),date_from_nullable=DFrom,per_mode_detailed='PerGame')
472 stats=statfind.get_data_frames()[0]
473 stats.rename(columns={'CFPARAMS': 'TEAM_NAME'})
~\anaconda3\lib\site-packages\requests\api.py in request(method, url, kwargs)
57 # cases, and look like a memory leak in others.
58 with sessions.Session() as session:
---> 59 return session.request(method=method, url=url, kwargs)
60
61
~\anaconda3\lib\site-packages\requests\sessions.py in send(self, request, kwargs)
701
702 # Send the request
--> 703 r = adapter.send(request, kwargs)
704
705 # Total elapsed time of the request (approximately)
from nba_api.stats.endpoints import leaguedashteamstats
import pandas as pd
import time
from nba_api.stats.endpoints import *
from nba_api.stats.endpoints import leaguedashteamstats
import os
from datetime import datetime
import platform
import warnings
warnings.filterwarnings('ignore')
warnings.warn('DelftStack')
warnings.warn('Do not show this message')
import schedule
NBA API Version
1.3.1
Issue
timeout Traceback (most recent call last) ~\anaconda3\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 444 # Otherwise it looks like a bug in the code. --> 445 six.raise_from(e, None) 446 except (SocketTimeout, BaseSSLError, SocketError) as e:
~\anaconda3\lib\site-packages\urllib3\packages\six.py in raise_from(value, from_value)
~\anaconda3\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 439 try: --> 440 httplib_response = conn.getresponse() 441 except BaseException as e:
~\anaconda3\lib\http\client.py in getresponse(self) 1370 try: -> 1371 response.begin() 1372 except ConnectionError:
~\anaconda3\lib\http\client.py in begin(self) 318 while True: --> 319 version, status, reason = self._read_status() 320 if status != CONTINUE:
~\anaconda3\lib\http\client.py in _read_status(self) 279 def _read_status(self): --> 280 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") 281 if len(line) > _MAXLINE:
~\anaconda3\lib\socket.py in readinto(self, b) 703 try: --> 704 return self._sock.recv_into(b) 705 except timeout:
~\anaconda3\lib\ssl.py in recv_into(self, buffer, nbytes, flags) 1240 self.class) -> 1241 return self.read(nbytes, buffer) 1242 else:
~\anaconda3\lib\ssl.py in read(self, len, buffer) 1098 if buffer is not None: -> 1099 return self._sslobj.read(len, buffer) 1100 else:
timeout: The read operation timed out
During handling of the above exception, another exception occurred:
ReadTimeoutError Traceback (most recent call last) ~\anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 485 try: --> 486 resp = conn.urlopen( 487 method=request.method,
~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 754 --> 755 retries = retries.increment( 756 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
~\anaconda3\lib\site-packages\urllib3\util\retry.py in increment(self, method, url, response, error, _pool, _stacktrace) 531 if read is False or not self._is_method_retryable(method): --> 532 raise six.reraise(type(error), error, _stacktrace) 533 elif read is not None:
~\anaconda3\lib\site-packages\urllib3\packages\six.py in reraise(tp, value, tb) 769 raise value.with_traceback(tb) --> 770 raise value 771 finally:
~\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 698 # Make the request on the httplib connection object. --> 699 httplib_response = self._make_request( 700 conn,
~\anaconda3\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 446 except (SocketTimeout, BaseSSLError, SocketError) as e: --> 447 self._raise_timeout(err=e, url=url, timeout_value=read_timeout) 448 raise
~\anaconda3\lib\site-packages\urllib3\connectionpool.py in _raise_timeout(self, err, url, timeout_value) 335 if isinstance(err, SocketTimeout): --> 336 raise ReadTimeoutError( 337 self, url, "Read timed out. (read timeout=%s)" % timeout_value
ReadTimeoutError: HTTPSConnectionPool(host='stats.nba.com', port=443): Read timed out. (read timeout=30)
During handling of the above exception, another exception occurred:
ReadTimeout Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_18104/3376019070.py in
488
489 while True:
--> 490 schedule.run_pending()
491 time.sleep(60) # wait one minute
~\anaconda3\lib\site-packages\schedule__init__.py in run_pending() 778 :data:
default scheduler instance <default_scheduler>
. 779 """ --> 780 default_scheduler.run_pending() 781 782~\anaconda3\lib\site-packages\schedule__init__.py in run_pending(self) 98 runnable_jobs = (job for job in self.jobs if job.should_run) 99 for job in sorted(runnable_jobs): --> 100 self._run_job(job) 101 102 def run_all(self, delay_seconds: int = 0) -> None:
~\anaconda3\lib\site-packages\schedule__init__.py in _run_job(self, job) 170 171 def _run_job(self, job: "Job") -> None: --> 172 ret = job.run() 173 if isinstance(ret, CancelJob) or ret is CancelJob: 174 self.cancel_job(job)
~\anaconda3\lib\site-packages\schedule__init__.py in run(self) 659 660 logger.debug("Running job %s", self) --> 661 ret = self.job_func() 662 self.last_run = datetime.datetime.now() 663 self._schedule_next_run()
~\AppData\Local\Temp/ipykernel_18104/3376019070.py in job(t) 469 470 #vs WESTERN CONFERENCE Off Stats --> 471 statfind = leaguedashteamstats.LeagueDashTeamStats(season=SZN, measure_type_detailed_defense=('Opponent'),date_to_nullable=DTo, vs_conference_nullable=('West'),date_from_nullable=DFrom,per_mode_detailed='PerGame') 472 stats=statfind.get_data_frames()[0] 473 stats.rename(columns={'CFPARAMS': 'TEAM_NAME'})
~\AppData\Roaming\Python\Python39\site-packages\nba_api\stats\endpoints\leaguedashteamstats.py in init(self, last_n_games, measure_type_detailed_defense, month, opponent_team_id, pace_adjust, per_mode_detailed, period, plus_minus, rank, season, season_type_all_star, conference_nullable, date_from_nullable, date_to_nullable, division_simple_nullable, game_scope_simple_nullable, game_segment_nullable, league_id_nullable, location_nullable, outcome_nullable, po_round_nullable, player_experience_nullable, player_position_abbreviation_nullable, season_segment_nullable, shot_clock_range_nullable, starter_bench_nullable, team_id_nullable, two_way_nullable, vs_conference_nullable, vs_division_nullable, proxy, headers, timeout, get_request) 86 } 87 if get_request: ---> 88 self.get_request() 89 90 def get_request(self):
~\AppData\Roaming\Python\Python39\site-packages\nba_api\stats\endpoints\leaguedashteamstats.py in get_request(self) 89 90 def get_request(self): ---> 91 self.nba_response = NBAStatsHTTP().send_api_request( 92 endpoint=self.endpoint, 93 parameters=self.parameters,
~\AppData\Roaming\Python\Python39\site-packages\nba_api\library\http.py in send_api_request(self, endpoint, parameters, referer, proxy, headers, timeout, raise_exception_on_error) 128 129 if not contents: --> 130 response = requests.get(url=base_url, params=parameters, headers=request_headers, proxies=proxies, timeout=timeout) 131 url = response.url 132 status_code = response.status_code
~\anaconda3\lib\site-packages\requests\api.py in get(url, params, kwargs) 71 """ 72 ---> 73 return request("get", url, params=params, kwargs) 74 75
~\anaconda3\lib\site-packages\requests\api.py in request(method, url, kwargs) 57 # cases, and look like a memory leak in others. 58 with sessions.Session() as session: ---> 59 return session.request(method=method, url=url, kwargs) 60 61
~\anaconda3\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 587 } 588 send_kwargs.update(settings) --> 589 resp = self.send(prep, **send_kwargs) 590 591 return resp
~\anaconda3\lib\site-packages\requests\sessions.py in send(self, request, kwargs) 701 702 # Send the request --> 703 r = adapter.send(request, kwargs) 704 705 # Total elapsed time of the request (approximately)
~\anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 530 raise SSLError(e, request=request) 531 elif isinstance(e, ReadTimeoutError): --> 532 raise ReadTimeout(e, request=request) 533 elif isinstance(e, _InvalidHeader): 534 raise InvalidHeader(e, request=request)
ReadTimeout: HTTPSConnectionPool(host='stats.nba.com', port=443): Read timed out. (read timeout=30)
Code
from nba_api.stats.endpoints import leaguedashteamstats
import pandas as pd import time
from nba_api.stats.endpoints import *
from nba_api.stats.endpoints import leaguedashteamstats import os from datetime import datetime import platform import warnings warnings.filterwarnings('ignore') warnings.warn('DelftStack') warnings.warn('Do not show this message') import schedule
def job(t): print("I'm working..."), t
schedule.every().day.at("11:35").do(job,'It is 05:00')
while True: schedule.run_pending() time.sleep(60) # wait one minute