Linked Questions
43 questions linked to/from Correct way to try/except using Python requests module?
0
votes
2
answers
2k
views
Printing out errors with Requests library [duplicate]
http://www.mobify.com/blog/http-requests-are-hard/ discusses various types of errors which can be encountered with a request. The article focuses on catching each one. I would like to simply print out ...
0
votes
1
answer
3k
views
How do I skip if the response is 404 using python requests? [duplicate]
for user in comments['comment_id']:
try:
get_profile(user)
except urllib.error.HTTPError:
continue
and I have gotten error like this, I don't know how to solve this problem
<ipython-...
2
votes
1
answer
1k
views
Python: Using requests and a loop with exception error to check if url exists [duplicate]
just wondered if somebody could help me tweak this loop:
I am trying to establish if url's exist but the loop is getting stuck when a url doesn't exist (due to the error of trying to find an non-...
0
votes
1
answer
982
views
python requests generic exception handling [duplicate]
Within my code, all requests have a timeout period. And for each request, I have to handle the Timeout exception. Is there any way to attach a global Timeout exception handler with the requests?
try:
...
0
votes
0
answers
231
views
How to handle requests exception in Python [duplicate]
I am doing multiple RESTful API calls using requests inside a loop. I would like to handle exceptions safely, without the script stopping. Here's my code:
try:
r = requests.get(url)
except ...
42
votes
1
answer
128k
views
Python requests - Exception Type: ConnectionError - try: except does not work
I am using a webservice to retrieve some data but sometimes the url is not working and my site is not loading. Do you know how I can handle the following exception so there is no problem with the site ...
10
votes
4
answers
23k
views
Capturing Response Body for a HTTP Error in python
Need to capture the response body for a HTTP error in python. Currently using the python request module's raise_for_status(). This method only returns the Status Code and description. Need a way to ...
9
votes
2
answers
29k
views
python Time a try except
My problem is very simple.
I have a try/except code. In the try I have some http requests attempts and in the except I have several ways to deal with the exceptions I'm getting.
Now I want to add a ...
10
votes
2
answers
19k
views
Socket-timeout: timed out python requests
Using the requests python lib, I make a GET request, and handle Timeout exceptions (as well as other exceptions I don't show here) like
import requests
timeout1=20
timeout2=40
try:
#first ...
4
votes
2
answers
14k
views
How to get the exception string from requests.exceptions.RequestException
I have the below flask code :
from flask import Flask,request,jsonify
import requests
from werkzeug.exceptions import InternalServerError, NotFound
import sys
import json
app = Flask(__name__)
app....
2
votes
3
answers
8k
views
Writing a unit test for Python REST API function
I'm currently learning Python REST API (side project). I've been reading a lot of tutorials from RealPython, Python Requests documentation, etc. I found this post on how to write try/except properly ...
4
votes
3
answers
9k
views
Catch proxy errors on requests python
I'm new on python so I'm having some trouble. I'm trying to build a tool that posts data to an external server with proxy. I have it working, but the problem is I don't know how to catch the proxy ...
6
votes
1
answer
2k
views
How to access server response when Python requests library encounters the retry limit
I am using the Python requests library to implement retry logic. Here is a simple script I made to reproduce the problem that I am having. In the case where we run out of retries, I would like to be ...
1
vote
3
answers
12k
views
How to check the connectivity for a URL in python
My requirement is almost same as Requests — how to tell if you're getting a success message?
But I need to print error whenever I could not reach the URL..Here is my try..
# setting up the URL and ...
3
votes
2
answers
10k
views
Get short version of error message with requests
I'm using requests and I need a shortened description of the exception,
try:
resp = requests.get(url)
except Exception, e:
data['error'] = str(e)
e.g for a connection error, str(e) becomes ('...