Why am I getting these errors and how to fix them?
Question: When I run this script I get a ton of errors. import urllib, urllib2

    
    
    proxy = urllib2.ProxyHandler({
        'http': '127.0.0.1',
        'https': '127.0.0.1'
    })
    opener = urllib2.build_opener(proxy)
    urllib2.install_opener(opener)
    # this way both http and https requests go through the proxy
    urllib2.urlopen('http://www.google.com')
    urllib2.urlopen('https://www.google.com')
    

I don't really understand what these errors are, hence why I am asking. Here
they are:

    
    
    Traceback (most recent call last):
      File "C:\Python27\Craig.py", line 10, in <module>
        urllib2.urlopen('http://www.google.com')
      File "C:\Python27\lib\urllib2.py", line 127, in urlopen
        return _opener.open(url, data, timeout)
      File "C:\Python27\lib\urllib2.py", line 410, in open
        response = meth(req, response)
      File "C:\Python27\lib\urllib2.py", line 523, in http_response
        'http', request, response, code, msg, hdrs)
      File "C:\Python27\lib\urllib2.py", line 448, in error
        return self._call_chain(*args)
      File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
        result = func(*args)
      File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
        raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    urllib2.HTTPError: HTTP Error 501: Not Implemented
    

Update: After I added the ports I got these errors:

Traceback (most recent call last): File "C:\Python27\Craig.py", line 10, in
urllib2.urlopen('<http://www.google.com>') File "C:\Python27\lib\urllib2.py",
line 127, in urlopen return _opener.open(url, data, timeout) File
"C:\Python27\lib\urllib2.py", line 404, in open response = self._open(req,
data) File "C:\Python27\lib\urllib2.py", line 422, in _open '_open', req) File
"C:\Python27\lib\urllib2.py", line 382, in _call_chain result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1214, in http_open return
self.do_open(httplib.HTTPConnection, req) File "C:\Python27\lib\urllib2.py",
line 1184, in do_open raise URLError(err) urllib2.URLError:


Answer: Are you running a local proxy?

If you are, it's probably not running on port 80. The default port is 3128.

    
    
    proxy = urllib2.ProxyHandler({
        'http': 'http://127.0.0.1:3128/',
        'https': 'http://127.0.0.1:3128/'
    })
    

