]> git.phdru.name Git - bookmarks_db.git/commitdiff
Feat(robots): Handle HTTP redirect 308
authorOleg Broytman <phd@phdru.name>
Tue, 14 Nov 2023 23:27:46 +0000 (02:27 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 14 Nov 2023 23:27:46 +0000 (02:27 +0300)
Robots/bkmk_robot_base.py
Robots/bkmk_rurllib.py
Robots/bkmk_rurllib2.py
Robots/bkmk_rurllib_py3.py

index 85c704a64955608c5add79747020d2b48ea74889..1d762d94d1713f951d583f120d658f2f9f8d17dd 100644 (file)
@@ -29,10 +29,11 @@ from parse_html import parse_html
 
 
 reloc_dict = {
-  301: "perm.",
+  301: "perm1.",
   302: "temp2.",
   303: "temp3.",
   307: "temp7.",
+  308: "temp8.",
   "html": "html"
 }
 
index 93dbae8c62378297ed3fd013f3a56c129cbfb954..067799c737271b5ceeb373eeb321bc12eaf1e7ec 100644 (file)
@@ -41,6 +41,8 @@ class MyURLopener(urllib.URLopener):
     http_error_303 = http_error_301
     # Error 307 -- relocated (temporarily)
     http_error_307 = http_error_301
+    # Error 308 -- relocated (permanently)
+    http_error_308 = http_error_301
 
     # Error 401 -- authentication required
     def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
index 66f04600135d648b281e52952a3e53c84d44bc22..1233c70aee1912d9047864f385e1140fd157ac5c 100644 (file)
@@ -66,7 +66,7 @@ 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))
index 9493a589556a2aaeba7a88925a8b6a27344cfb3b..1daec389aebaa27f3eb502cc2ef2016310dbea4c 100644 (file)
@@ -43,6 +43,8 @@ class MyURLopener(urllib.request.URLopener):
     http_error_303 = http_error_301
     # Error 307 -- relocated (temporarily)
     http_error_307 = http_error_301
+    # Error 308 -- relocated (permanently)
+    http_error_308 = http_error_301
 
     # Error 401 -- authentication required
     def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):