-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
网页可以访问‘http://127.0.0.1:5010/get/',但requests.get('http://127.0.0.1:5010/get/') 返回503状态码 #385
Comments
你启动成功了吗 贴后台日志, |
*** ______ ********************* ______ *********** _ ******** *** ______ ********************* ______ *********** _ ******** 2019-11-04 22:43:41,244 ProxyScheduler.py[line:33] INFO start fetch proxy 使用浏览器可以正常获取,但使用requests库就不行, import requests
test = requests.get(url="http://127.0.0.1:5010/get/").json()
print(test) 结果: import requests
test = requests.get(url="http://127.0.0.1:5010/get/")
print(test) 结果: |
request和浏览器没区别,如果浏览器能正常使用,那么检查你的代码和环境 |
请问找到解决方法了吗?我也碰到这个问题了 |
没有解决,我已经放弃了,哎
发自我的iPhone
… 在 2020年2月12日,上午9:22,mj2selina ***@***.***> 写道:
请问找到解决方法了吗?我也碰到这个问题了
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
经过我不懈的努力,在stackoverflow找到解决方案了
import os
import requests
os.environ['NO_PROXY'] = '127.0.0.1'
r = requests.get('http://127.0.0.1:5010/get/')
print(r)
… On Feb 12, 2020, at 10:09, 米黄色小绵羊 ***@***.***> wrote:
没有解决,我已经放弃了,哎
发自我的iPhone
> 在 2020年2月12日,上午9:22,mj2selina ***@***.***> 写道:
>
>
> 请问找到解决方法了吗?我也碰到这个问题了
>
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub <#385?email_source=notifications&email_token=AJ3GPK542WHOTWKCPBWYJV3RCNFN5A5CNFSM4JH4MQ4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELO6VEA#issuecomment-584968848>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJ3GPK6XCN6IMYB6SHYZKCTRCNFN5ANCNFSM4JH4MQ4A>.
>
|
'''python
import requests
print(requests.get('http://127.0.0.1:5010/get/').json())
'''
JSONDecodeError Traceback (most recent call last)
in
----> 1 requests.get("http://127.0.0.1:5010/get/").json()
~/.pyenv/versions/3.5.2/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/models.py in json(self, **kwargs)
895 # used.
896 pass
--> 897 return complexjson.loads(self.text, **kwargs)
898
899 @Property
~/.pyenv/versions/3.5.2/Python.framework/Versions/3.5/lib/python3.5/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
317 parse_int is None and parse_float is None and
318 parse_constant is None and object_pairs_hook is None and not kw):
--> 319 return _default_decoder.decode(s)
320 if cls is None:
321 cls = JSONDecoder
~/.pyenv/versions/3.5.2/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py in decode(self, s, _w)
337
338 """
--> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()
341 if end != len(s):
~/.pyenv/versions/3.5.2/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py in raw_decode(self, s, idx)
355 obj, end = self.scan_once(s, idx)
356 except StopIteration as err:
--> 357 raise JSONDecodeError("Expecting value", s, err.value) from None
358 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我猜测可能是没有返回内容才导致报错,
‘’‘python
print(requests.get('http://127.0.0.1:5010/get/')
'''
<Response [503]>
如上所示,返回了503状态码
但是我打开浏览器访问 http://127.0.0.1:5010/get/ 却能正确显示内容
平台:MacOS Catalina, Version 10.15.1
Python版本:3.5.2
The text was updated successfully, but these errors were encountered: