【发布时间】:2017-11-25 14:11:10
【问题描述】:
我正在尝试运行以下 sn-p 代码以从指定的 url 检索数据。我尝试使用 'timeout=5' 参数并将其排除在外。
最终结果是运行脚本要么挂起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)
【问题讨论】:
标签: python python-3.x python-requests response urllib