Просмотр исходного кода

Improve static URL detection

Add go parameter and CNET's URL-in-path method
RichardG867 5 лет назад
Родитель
Сommit
7b3deb24d9
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      waybackproxy.py

+ 3 - 1
waybackproxy.py

@@ -117,7 +117,9 @@ class Handler(socketserver.BaseRequestHandler):
 
 			# 403 or 404 => heuristically determine the static URL for some redirect scripts
 			if e.code in (403, 404):
-				match = re.search('''(?:\?|&)(?:target|trg|dest(?:ination)?|to)?(?:url)?=(http[^&]+)''', archived_url, re.IGNORECASE)
+				match = re.search('''(?:\?|&)(?:target|trg|dest(?:ination)?|to|go)?(?:url)?=(http[^&]+)''', archived_url, re.IGNORECASE)
+				if not match:
+					match = re.search('''/(?:target|trg|dest(?:ination)?|to|go)?(?:url)?/(http.+)''', archived_url, re.IGNORECASE)
 				if match:
 					# we found it
 					new_url = urllib.parse.unquote_plus(match.group(1))