python-requests.get()返回:400 >>用户代理='Mozilla/5.0(Windows NT 6.1;WOW64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/30.0.1599.101 Safari/537.36' >>>url='http://xueqiu.com/stock/quote.json?code=' >>>results=requests.get(url,params={'q':'SZ000858'},headers={'User-Agent':User\u-Agent}) >>>打印结果
上面是我想从url获取数据的代码,而结果显示为“response[400]”。这看起来是一个错误的请求。我无法找出问题所在并寻求解决方案。提前感谢。我尝试了你的代码,我得到了python-requests.get()返回:400 >>用户代理='Mozilla/5.0(Windows NT 6.1;WOW64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/30.0.1599.101 Safari/537.36' >>>url='http://xueqiu.com/stock/quote.json?code=' >>>results=requests.get(url,params={'q':'SZ000858'},headers={'User-Agent':User\u-Agent}) >>>打印结果,python,python-requests,Python,Python Requests,上面是我想从url获取数据的代码,而结果显示为“response[400]”。这看起来是一个错误的请求。我无法找出问题所在并寻求解决方案。提前感谢。我尝试了你的代码,我得到了api\u无效\u访问\u令牌,这意味着你需要一个api令牌才能使用它 在使用API之前,您可能需要查看它的文档。您很可能需要首先向提供商注册。>>r=requests.get(')>>>r.status\u code 400>>>r.text u'{“error\u description”:“api\u invalid\
api\u无效\u访问\u令牌
,这意味着你需要一个api令牌才能使用它
在使用API之前,您可能需要查看它的文档。您很可能需要首先向提供商注册。>>r=requests.get(')>>>r.status\u code 400>>>r.text u'{“error\u description”:“api\u invalid\u access\u token”,“error\u uri”:“/stock/quote.json”,“error\u code”:“400016”}”是的,正如代码所示,这是我面临的问题,如何解决它?@schloss我对API一无所知,甚至不知道如何找到它的文档。我真的帮不了你这个小消息。
>>>user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36'
>>>url = 'http://xueqiu.com/stock/quote.json?code='
>>>results = requests.get(url,params={'q': 'SZ000858'}, headers={'User-Agent': user_agent})
>>>print results
<Response [400]>