__all__ = ['robot_urllib']
-import os
import sys
-import time
import urllib
from Robots.bkmk_robot_base import robot_base, get_error
class MyURLopener(urllib.URLopener):
# Error 301 -- relocated (permanently)
def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
- if headers.has_key('location'):
+ if 'location' in headers:
newurl = headers['location']
- elif headers.has_key('uri'):
+ elif 'uri' in headers:
newurl = headers['uri']
else:
newurl = "Nowhere"
def http_error_default(self, url, fp, errcode, errmsg, headers):
if fp:
- void = fp.read()
+ fp.read()
fp.close()
raise IOError(('http error', errcode, errmsg, headers))
if (e[0] == "http error") and (e[1] == -1):
error = None
bookmark.no_error = "The server did not return any header - "
- "it is not an error, actually"
+ "it is not an error, actually"
self.log(' no headers: %s' % bookmark.no_error)
else:
error = get_error(e)