【发布时间】:2017-03-18 18:24:43
【问题描述】:
我正在尝试从本地服务器上抓取我自己的网站。但是当我对它使用python请求时,它给了我一个响应503。网络上的其他普通站点工作。有什么原因/解决方案吗?
import requests
url = 'http://127.0.0.1:8080/full_report/a1uE0000002vu2jIAA/'
r = requests.get(url)
print r
打印出来
<Response [503]>
经过进一步调查,我发现了与我类似的问题。 Python requests 503 erros when trying to access localhost:8000
但是,我认为他还没有解决这个问题。我可以通过网络浏览器访问本地网站,但无法使用 requests.get 功能访问。我也在使用 Django 来托管服务器。
python manage.py runserver 8080
当我使用: curl -vvv http://127.0.0.1:8080
* Rebuilt URL to: http://127.0.0.1:8080/
* Trying 10.37.135.39...
* Connected to proxy.kdc.[company-name].com (10.37.135.39) port 8099 (#0)
* Proxy auth using Basic with user '[company-id]'
> GET http://127.0.0.1:8080/ HTTP/1.1
> Host: 127.0.0.1:8080
> Proxy-Authorization: Basic Y2FhNTc2OnJ2YTkxQ29kZQ==
> User-Agent: curl/7.49.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: BlueCoat-Security-Appliance
< Location:http://10.118.216.201
< Connection: Close
<
<HTML>
<HEAD><TITLE>Redirection</TITLE></HEAD>
<BODY><H1>Redirect</H1></BODY>
* Closing connection 0
【问题讨论】:
-
他确实解决了这个问题 - 如果您阅读了 cmets。 发现发生了什么,我们有一个内部软件干扰了端口。因此,当我在家用电脑上试用时,它运行良好。
-
您的 url 中没有指定端口号。 Django 在
http://127.0.0.1:8000/运行默认服务器,所以你应该尝试url = 'http://127.0.0.1:8000/full_report/a1uE0000002vu2jIAA/' -
没有看到最后一行所以上面的命令url应该是
http://127.0.0.1:8080/.... -
我忘记编辑那部分了。端口 8080 也不能正常工作。我编辑了帖子以反映这一点。
-
如果你
curl -vvv http://127.0.0.1:8080会发生什么?
标签: python django python-requests