0
我试图运行下面的代码片段来从指定的URL检索数据。我尝试使用'timeout = 5'参数以及将其保留。response.get()不返回或超时
最终的结果是,运行脚本要么挂起python,要么出现超时错误消息?在浏览器中打开url似乎会返回有效的json,但我似乎无法在python中抓取数据。
这是怎么回事?
import requests
url = "http://stats.nba.com/stats/shotchartdetail?Period=0&VsConference=&LeagueID=00&LastNGames=0&TeamID=0&Position=&Location=&Outcome=&ContextMeasure=FGA&DateFrom=&StartPeriod=&DateTo=&OpponentTeamID=0&ContextFilter=&RangeType=&Season=2016-17&AheadBehind=&PlayerID=202738&EndRange=&VsDivision=&PointDiff=&RookieYear=&GameSegment=&Month=0&ClutchTime=&StartRange=&EndPeriod=&SeasonType=Regular+Season&SeasonSegment=&GameID=&PlayerPosition="
response = requests.get(url,timeout=5)
print(response)
是的,这个问题解决了,谢谢。 – trystuff