Python requests.exceptions.ConnectionError

Source: Internet
Author: User

Today, I have a wonderful problem,

1.r.request.post (URL)

2..print R. Status_code

Actually the first step of the error, because the URL is not correct, according to the truth should be able to go to the second step and then enter 404

Import Requeststry:requests.get ("Http://not.a.real.url/really_not") except Requests.exceptions.ConnectionError as E : Pass>>> Econnectionerror (Maxretryerror ("Httpconnectionpool" (host= ' Not.a.real.url ', port=80): Max retries Exceeded with URL:/really_not (caused by <class ' socket.gaierror ';: [Errno-2] Name or service not known) ",), >& Gt;> E.args (Maxretryerror ("Httpconnectionpool (host= ' Not.a.real.url ', port=80): Max retries exceeded with URL:/ Really_not (caused by <class ' socket.gaierror ';: [Errno-2] Name or service not known) ', '), >>> E.args[0]max Retryerror ("Httpconnectionpool (host= ' Not.a.real.url ', port=80): Max retries exceeded with URL:/really_not (Caused by & Lt;class ' socket.gaierror ': [Errno-2] Name or service not known) ', ' >>> dir (e.args[0]) [' __class__ ', ' __ Delattr__ ', ' __dict__ ', ' __doc__ ', ' __format__ ', ' __getattribute__ ', ' __getitem__ ', ' __getslice__ ', ' __hash__ ', ' __ Init__ ', ' __module__ ', ' __new__ ', ' __reduce__ ', ' __reducE_ex__ ', ' __repr__ ', ' __setattr__ ', ' __setstate__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' __unicode__ ', ' __ Weakref__ ', ' args ', ' message ', ' pool ', ' reason ', ' url ']>>> e.args[0].reasongaierror ( -2, ' Name ' or ' service not ' kno Wn ') >>> dir (e.args[0].reason) [' __class__ ', ' __delattr__ ', ' __dict__ ', ' __doc__ ', ' __format__ ', ' __ getattribute__ ', ' __getitem__ ', ' __getslice__ ', ' __hash__ ', ' __init__ ', ' __module__ ', ' __new__ ', ' __reduce__ ', ' __ Reduce_ex__ ', ' __repr__ ', ' __setattr__ ', ' __setstate__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' __unicode__ ', ' __weakref__ ', ' args ', ' errno ', ' filename ', ' message ', ' strerror ']>>> e.args[0].reason.errno-2

  

 

Python requests.exceptions.ConnectionError

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.