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