X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Robots%2Fbkmk_rurllib2.py;h=1233c70aee1912d9047864f385e1140fd157ac5c;hb=011586eca56d3bde3fef2087579e6cbc0682f5b4;hp=a5714a19abd4e0d1c0e2b76404d23b0dd143f129;hpb=97202bf84e9c78d8fac912a82a85fb1cbb233a4b;p=bookmarks_db.git diff --git a/Robots/bkmk_rurllib2.py b/Robots/bkmk_rurllib2.py index a5714a1..1233c70 100644 --- a/Robots/bkmk_rurllib2.py +++ b/Robots/bkmk_rurllib2.py @@ -5,7 +5,7 @@ This file is a part of Bookmarks database and Internet robot. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2014-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 2014-2023 PhiloSoft Design" __license__ = "GNU GPL" __all__ = ['robot_urllib2'] @@ -19,6 +19,7 @@ from Robots.bkmk_robot_base import robot_base, get_error _fw = None + class FTPHandler(urllib2.FTPHandler): def connect_ftp(self, user, passwd, host, port, dirs, timeout): global _fw @@ -39,7 +40,8 @@ urllib2.install_opener(opener) # Fake headers to pretend this is a real browser -_user_agent = "Mozilla/5.0 (X11; Linux i686; rv:30.0) Gecko/20100101 Firefox/30.0" +_user_agent = "Mozilla/5.0 (X11; Linux i686; rv:30.0)" +" Gecko/20100101 Firefox/30.0" _x_user_agent = "bookmarks_db (Python %d.%d.%d; urllib2)" % ( sys.version_info[0], sys.version_info[1], sys.version_info[2]) @@ -64,11 +66,12 @@ class robot_urllib2(robot_base): response = urllib2.urlopen(request) except urllib2.HTTPError as e: - if e.code in (301, 302, 303, 307): + if e.code in (301, 302, 303, 307, 308): return None, e.code, e.hdrs['Location'], None, None else: self.log(' HTTP Error %s: %s' % (e.code, e.msg)) - return "HTTP Error %s: %s" % (e.code, e.msg), None, None, None, None + return ("HTTP Error %s: %s" % (e.code, e.msg), + None, None, None, None) except urllib2.URLError as e: self.log(' URL Error: %s' % e.reason)