Getting error text from `urllib2.urlopen`

I used Python urllib2.urlopenand received 500 errors from the server. How to find the error text? I hope he has useful information.

+3
source share
1 answer
from urllib2 import urlopen, HTTPError

try:
    f = urlopen(url)
except HTTPError, e:
    print(e.read())
+4
source

All Articles