0

I'm trying to change my python code from 2.7 to 3.6

So, I'm not familiar to python but I have error with urllib2 I have this error

Error Contents: name 'urllib2' is not defined

So I do this:

from urllib.request import urlopen

This is maybe ok, because urllib2 doesn't work on phyton 3? But I have this:

class NoRedirection(urllib2.HTTPErrorProcessor):
   def http_response(self, request, response):
       return response
   https_response = http_response

What I tried to change

class NoRedirection(urlopen.HTTPErrorProcessor):

But does't work. How to fix this?

 **AttributeError: 'function' object has no attribute 'HTTPErrorProcessor'**
Aleksandar
  • 59
  • 1
  • 7

1 Answers1

0

There is a separate module for errors found here. What you want to do is something along these lines

from urllib.error import HTTPError

class NoRedirection(HTTPError):
    ...
gold_cy
  • 13,648
  • 3
  • 23
  • 45