Linked Questions

0 votes
2 answers
2k views

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 ...
user1592380's user avatar
  • 36.9k
0 votes
1 answer
3k views

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-...
Pantaporn Benjachairat's user avatar
2 votes
1 answer
1k views

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-...
ewldh20's user avatar
  • 83
0 votes
1 answer
982 views

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: ...
Minuddin Ahmed Rana's user avatar
0 votes
0 answers
231 views

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 ...
Xavier Ashe's user avatar
42 votes
1 answer
128k views

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 ...
user1431148's user avatar
10 votes
4 answers
23k views

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 ...
Anupam Nair's user avatar
9 votes
2 answers
29k views

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 ...
Eran Moshe's user avatar
  • 3,238
10 votes
2 answers
19k views

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 ...
fpghost's user avatar
  • 2,974
4 votes
2 answers
14k views

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....
Subhayan Bhattacharya's user avatar
2 votes
3 answers
8k views

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 ...
ThomasWest's user avatar
4 votes
3 answers
9k views

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 ...
William James's user avatar
6 votes
1 answer
2k views

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 ...
Brett Widmeier's user avatar
1 vote
3 answers
12k views

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 ...
Pathi's user avatar
  • 133
3 votes
2 answers
10k views

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 ('...
daisy's user avatar
  • 23.7k

15 30 50 per page