Python Forum
HTTP response capturing issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTTP response capturing issue
#1
I want to catch a specific HTTP error and not any one of the entire family.. what I was trying to do is
import urllib2
try:
   urllib2.urlopen("some url")
except urllib2.HTTPError:
   <whatever>
but what I end up is catching any kind of HTTP error, but I want to catch only if the specified webpage doesn't exist!! probably that's HTTP error 404..but I don't know how to specify that catch only error 404 and let the system run the default handler for other events.
Reply
#2
that should only capture the urllib2.HTTPError.
what makes you think it doesn't?
If it's because you still see the other errors, that's because they were not captured but rather sent to stderr which is usual.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Capturing BS4 values into DF and writing to CSV cubangt 18 1,965 Sep-05-2023, 01:57 PM
Last Post: cubangt
  capturing multiline output for number of parameters jss 3 820 Sep-01-2023, 05:42 PM
Last Post: jss
  Json filter is not capturing desired key/element mrapple2020 1 1,138 Nov-24-2022, 09:22 AM
Last Post: ibreeden
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 15,468 Jun-25-2020, 08:58 AM
Last Post: buran
  Capturing inputs values from internal python script limors11 11 5,210 Jun-16-2019, 05:05 PM
Last Post: DeaD_EyE
  Capturing a snapshot from the video sreeramp96 1 2,183 May-24-2019, 07:02 AM
Last Post: heiner55
  httplib to http.client conversion issue zatlas1 1 2,580 Apr-12-2019, 05:21 PM
Last Post: Larz60+
  HTTP response capturing issue anna 2 2,507 Mar-15-2019, 03:08 PM
Last Post: Larz60+
  HTTP 400 response code eshwinsukhdeve 1 1,734 Mar-03-2019, 06:11 PM
Last Post: Larz60+
  Capturing error from sql Grego 1 2,458 Jun-29-2018, 11:17 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020