python requests.get()继续获得401

时间:2016-04-18 18:34:56

标签: python http web ipython python-requests

我想完成的任务非常简单。使用python做一个http get请求。 以下是我使用的代码:

url = 'http://www.costcobusinessdelivery.com/AjaxWarehouseBrowseLookupView?storeId=11301&catalogId=11701&langId=-1&parentGeoNode=10112'

requests.get(url)

然后我得到了:

<Response [401]>

我是python的新手,有人可以帮忙吗?谢谢!

更新 根据评论。似乎代码没问题,但我确实得到了401响应。我怀疑我公司的网络有一些限制吗?但我可以通过浏览器访问并获得有效的响应。有没有办法绕过我公司的防火墙/代理或其他什么?只是假装我在python中使用浏览器?再次感谢!

1 个答案:

答案 0 :(得分:1)

如果您的浏览器通过代理服务器访问网络,请查看您的浏览器设置并在python中使用它。

r = requests.get(url,                  proxies = {&#34; http&#34;:&#34; http://61.233.25.166:80&#34;})

您的代理服务器将具有不同的地址。