Amazon wishlist optimizer

 --> -->
      
 
 
<class 'urllib2.HTTPError'>
Python 2.7.18: /usr/local/bin/python
Tue May 14 08:20:27 2024

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /home/majid/web/root/cgi/amawish.cgi in <module>()
    159     cached = True
    160   except (IOError, OSError, ValueError):
=>  161     items = parse_wl(wl_id)
    162     f = open('/tmp/amawish/' + wl_id, 'w')
    163     cPickle.dump(items, f)
items undefined, parse_wl = <function parse_wl>, wl_id = 'P735P8BBZV3S'
 /home/majid/web/root/cgi/amawish.cgi in parse_wl(wl_id='P735P8BBZV3S')
     17   print '<pre>'
     18   while page <= maxpage:
=>   19     data = urllib2.urlopen(url + '&page=%d' % page).read()
     20     soup = BeautifulSoup(data).fetch('form', {'name': 'editItems'})[0]
     21     for item in soup.fetch('tr')[1:]:
data undefined, global urllib2 = <module 'urllib2' from '/usr/local/lib/python2.7/urllib2.pyc'>, urllib2.urlopen = <function urlopen>, url = 'http://www.amazon.com/registry/wishlist/P735P8BB...rchased&filter=all&sort=date-added&layout=compact', page = 1, ).read undefined
 /usr/local/lib/python2.7/urllib2.py in urlopen(url='http://www.amazon.com/registry/wishlist/P735P8BB...&filter=all&sort=date-added&layout=compact&page=1', data=None, timeout=<object object>, cafile=None, capath=None, cadefault=False, context=None)
    152     else:
    153         opener = _opener
=>  154     return opener.open(url, data, timeout)
    155 
    156 def install_opener(opener):
opener = <urllib2.OpenerDirector instance>, opener.open = <bound method OpenerDirector.open of <urllib2.OpenerDirector instance>>, url = 'http://www.amazon.com/registry/wishlist/P735P8BB...&filter=all&sort=date-added&layout=compact&page=1', data = None, timeout = <object object>
 /usr/local/lib/python2.7/urllib2.py in open(self=<urllib2.OpenerDirector instance>, fullurl='http://www.amazon.com/registry/wishlist/P735P8BB...&filter=all&sort=date-added&layout=compact&page=1', data=None, timeout=<object object>)
    433         for processor in self.process_response.get(protocol, []):
    434             meth = getattr(processor, meth_name)
=>  435             response = meth(req, response)
    436 
    437         return response
response = <addinfourl at 139935595483296 whose fp = None>, meth = <bound method HTTPErrorProcessor.http_response of <urllib2.HTTPErrorProcessor instance>>, req = <urllib2.Request instance>
 /usr/local/lib/python2.7/urllib2.py in http_response(self=<urllib2.HTTPErrorProcessor instance>, request=<urllib2.Request instance>, response=<addinfourl at 139935595483296 whose fp = None>)
    546         if not (200 <= code < 300):
    547             response = self.parent.error(
=>  548                 'http', request, response, code, msg, hdrs)
    549 
    550         return response
request = <urllib2.Request instance>, response = <addinfourl at 139935595483296 whose fp = None>, code = 301, msg = 'Moved Permanently', hdrs = <httplib.HTTPMessage instance>
 /usr/local/lib/python2.7/urllib2.py in error(self=<urllib2.OpenerDirector instance>, proto=301, *args=({301: [<urllib2.HTTPRedirectHandler instance>], 302: [<urllib2.HTTPRedirectHandler instance>], 303: [<urllib2.HTTPRedirectHandler instance>], 307: [<urllib2.HTTPRedirectHandler instance>], 'default': [<urllib2.HTTPDefaultErrorHandler instance>]}, 301, 'http_error_301', <urllib2.Request instance>, <addinfourl at 139935595483296 whose fp = None>, 301, 'Moved Permanently', <httplib.HTTPMessage instance>))
    465             http_err = 0
    466         args = (dict, proto, meth_name) + args
=>  467         result = self._call_chain(*args)
    468         if result:
    469             return result
result undefined, self = <urllib2.OpenerDirector instance>, self._call_chain = <bound method OpenerDirector._call_chain of <urllib2.OpenerDirector instance>>, args = ({301: [<urllib2.HTTPRedirectHandler instance>], 302: [<urllib2.HTTPRedirectHandler instance>], 303: [<urllib2.HTTPRedirectHandler instance>], 307: [<urllib2.HTTPRedirectHandler instance>], 'default': [<urllib2.HTTPDefaultErrorHandler instance>]}, 301, 'http_error_301', <urllib2.Request instance>, <addinfourl at 139935595483296 whose fp = None>, 301, 'Moved Permanently', <httplib.HTTPMessage instance>)
 /usr/local/lib/python2.7/urllib2.py in _call_chain(self=<urllib2.OpenerDirector instance>, chain={301: [<urllib2.HTTPRedirectHandler instance>], 302: [<urllib2.HTTPRedirectHandler instance>], 303: [<urllib2.HTTPRedirectHandler instance>], 307: [<urllib2.HTTPRedirectHandler instance>], 'default': [<urllib2.HTTPDefaultErrorHandler instance>]}, kind=301, meth_name='http_error_301', *args=(<urllib2.Request instance>, <addinfourl at 139935595483296 whose fp = None>, 301, 'Moved Permanently', <httplib.HTTPMessage instance>))
    405             func = getattr(handler, meth_name)
    406 
=>  407             result = func(*args)
    408             if result is not None:
    409                 return result
result undefined, func = <bound method HTTPRedirectHandler.http_error_302 of <urllib2.HTTPRedirectHandler instance>>, args = (<urllib2.Request instance>, <addinfourl at 139935595483296 whose fp = None>, 301, 'Moved Permanently', <httplib.HTTPMessage instance>)
 /usr/local/lib/python2.7/urllib2.py in http_error_302(self=<urllib2.HTTPRedirectHandler instance>, req=<urllib2.Request instance>, fp=<addinfourl at 139935595483296 whose fp = None>, code=301, msg='Moved Permanently', headers=<httplib.HTTPMessage instance>)
    652         fp.close()
    653 
=>  654         return self.parent.open(new, timeout=req.timeout)
    655 
    656     http_error_301 = http_error_303 = http_error_307 = http_error_302
self = <urllib2.HTTPRedirectHandler instance>, self.parent = <urllib2.OpenerDirector instance>, self.parent.open = <bound method OpenerDirector.open of <urllib2.OpenerDirector instance>>, new = <urllib2.Request instance>, timeout undefined, req = <urllib2.Request instance>, req.timeout = <object object>
 /usr/local/lib/python2.7/urllib2.py in open(self=<urllib2.OpenerDirector instance>, fullurl=<urllib2.Request instance>, data=None, timeout=<object object>)
    433         for processor in self.process_response.get(protocol, []):
    434             meth = getattr(processor, meth_name)
=>  435             response = meth(req, response)
    436 
    437         return response
response = <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>, meth = <bound method HTTPErrorProcessor.http_response of <urllib2.HTTPErrorProcessor instance>>, req = <urllib2.Request instance>
 /usr/local/lib/python2.7/urllib2.py in http_response(self=<urllib2.HTTPErrorProcessor instance>, request=<urllib2.Request instance>, response=<addinfourl at 139935595621104 whose fp = <socket._fileobject object>>)
    546         if not (200 <= code < 300):
    547             response = self.parent.error(
=>  548                 'http', request, response, code, msg, hdrs)
    549 
    550         return response
request = <urllib2.Request instance>, response = <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>, code = 503, msg = 'Service Unavailable', hdrs = <httplib.HTTPMessage instance>
 /usr/local/lib/python2.7/urllib2.py in error(self=<urllib2.OpenerDirector instance>, proto=503, *args=({301: [<urllib2.HTTPRedirectHandler instance>], 302: [<urllib2.HTTPRedirectHandler instance>], 303: [<urllib2.HTTPRedirectHandler instance>], 307: [<urllib2.HTTPRedirectHandler instance>], 'default': [<urllib2.HTTPDefaultErrorHandler instance>]}, 'default', 'http_error_default', <urllib2.Request instance>, <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>, 503, 'Service Unavailable', <httplib.HTTPMessage instance>))
    471         if http_err:
    472             args = (dict, 'default', 'http_error_default') + orig_args
=>  473             return self._call_chain(*args)
    474 
    475 # XXX probably also want an abstract factory that knows when it makes
self = <urllib2.OpenerDirector instance>, self._call_chain = <bound method OpenerDirector._call_chain of <urllib2.OpenerDirector instance>>, args = ({301: [<urllib2.HTTPRedirectHandler instance>], 302: [<urllib2.HTTPRedirectHandler instance>], 303: [<urllib2.HTTPRedirectHandler instance>], 307: [<urllib2.HTTPRedirectHandler instance>], 'default': [<urllib2.HTTPDefaultErrorHandler instance>]}, 'default', 'http_error_default', <urllib2.Request instance>, <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>, 503, 'Service Unavailable', <httplib.HTTPMessage instance>)
 /usr/local/lib/python2.7/urllib2.py in _call_chain(self=<urllib2.OpenerDirector instance>, chain={301: [<urllib2.HTTPRedirectHandler instance>], 302: [<urllib2.HTTPRedirectHandler instance>], 303: [<urllib2.HTTPRedirectHandler instance>], 307: [<urllib2.HTTPRedirectHandler instance>], 'default': [<urllib2.HTTPDefaultErrorHandler instance>]}, kind='default', meth_name='http_error_default', *args=(<urllib2.Request instance>, <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>, 503, 'Service Unavailable', <httplib.HTTPMessage instance>))
    405             func = getattr(handler, meth_name)
    406 
=>  407             result = func(*args)
    408             if result is not None:
    409                 return result
result undefined, func = <bound method HTTPDefaultErrorHandler.http_error...lt of <urllib2.HTTPDefaultErrorHandler instance>>, args = (<urllib2.Request instance>, <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>, 503, 'Service Unavailable', <httplib.HTTPMessage instance>)
 /usr/local/lib/python2.7/urllib2.py in http_error_default(self=<urllib2.HTTPDefaultErrorHandler instance>, req=<urllib2.Request instance>, fp=<addinfourl at 139935595621104 whose fp = <socket._fileobject object>>, code=503, msg='Service Unavailable', hdrs=<httplib.HTTPMessage instance>)
    554 class HTTPDefaultErrorHandler(BaseHandler):
    555     def http_error_default(self, req, fp, code, msg, hdrs):
=>  556         raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    557 
    558 class HTTPRedirectHandler(BaseHandler):
global HTTPError = <class 'urllib2.HTTPError'>, req = <urllib2.Request instance>, req.get_full_url = <bound method Request.get_full_url of <urllib2.Request instance>>, code = 503, msg = 'Service Unavailable', hdrs = <httplib.HTTPMessage instance>, fp = <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>

<class 'urllib2.HTTPError'>: HTTP Error 503: Service Unavailable
      args = ()
      close = <bound method HTTPError.close of HTTPError()>
      code = 503
      errno = None
      filename = 'https://www.amazon.com/registry/wishlist/P735P8B...&filter=all&sort=date-added&layout=compact&page=1'
      fileno = <bound method _fileobject.fileno of <socket._fileobject object>>
      fp = <addinfourl at 139935595621104 whose fp = <socket._fileobject object>>
      getcode = <bound method HTTPError.getcode of HTTPError()>
      geturl = <bound method HTTPError.geturl of HTTPError()>
      hdrs = <httplib.HTTPMessage instance>
      headers = <httplib.HTTPMessage instance>
      info = <bound method HTTPError.info of HTTPError()>
      message = ''
      msg = 'Service Unavailable'
      next = <bound method _fileobject.next of <socket._fileobject object>>
      read = <bound method _fileobject.read of <socket._fileobject object>>
      readline = <bound method _fileobject.readline of <socket._fileobject object>>
      readlines = <bound method _fileobject.readlines of <socket._fileobject object>>
      reason = 'Service Unavailable'
      strerror = None
      url = 'https://www.amazon.com/registry/wishlist/P735P8B...&filter=all&sort=date-added&layout=compact&page=1'