1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Added google_redirect. Speedup.

This commit is contained in:
Witold Filipczyk 2006-09-02 12:07:29 +02:00 committed by Witold Filipczyk
parent d9037cc4c3
commit c5a6e58e64

View File

@ -1,11 +1,12 @@
import re import re
import sys
dumbprefixes = { dumbprefixes = {
"7th" : "http://7thguard.net/", "7th" : "http://7thguard.net/",
"b" : "http://babelfish.altavista.com/babelfish/tr", "b" : "http://babelfish.altavista.com/babelfish/tr/",
"bz" : "http://bugzilla.elinks.cz", "bz" : "http://bugzilla.elinks.cz/",
"bug" : "http://bugzilla.elinks.cz", "bug" : "http://bugzilla.elinks.cz/",
"d" : "http://www.dict.org", "d" : "http://www.dict.org/",
"g" : "http://www.google.com/", "g" : "http://www.google.com/",
"gg" : "http://www.google.com/", "gg" : "http://www.google.com/",
"go" : "http://www.google.com/", "go" : "http://www.google.com/",
@ -21,6 +22,14 @@ dumbprefixes = {
"sd" : "http://www.slashdot.org/" "sd" : "http://www.slashdot.org/"
} }
cygwin = re.compile("cygwin\.com")
cygwin_sub1 = re.compile('<body bgcolor="#000000" color="#000000"')
cygwin_sub2 = re.compile('<body bgcolor="#ffffff" color="#000000"')
mbank = re.compile('https://www\.mbank\.com\.pl/ib_navibar_3\.asp')
mbank_sub1 = re.compile('<td valign="top"><img')
mbank_sub2 = re.compile('<tr><td valign="top"><img')
google_redirect = re.compile('^http://www\.google\.com/url\?sa=D&q=(.*)')
def goto_url_hook(url, current_url): def goto_url_hook(url, current_url):
global dumbprefixes global dumbprefixes
@ -30,14 +39,17 @@ def goto_url_hook(url, current_url):
return None return None
def follow_url_hook(url): def follow_url_hook(url):
m = google_redirect.search(url)
if m:
return m.group(1)
return None return None
def pre_format_html_hook(url, html): def pre_format_html_hook(url, html):
if re.search("cygwin\.com", url): if cygwin.search(url):
html2 = re.sub("<body bgcolor=\"#000000\" color=\"#000000\"", "<body bgcolor=\"#ffffff\" color=\"#000000\"", html) re.sub(cygwin_sub1, cygwin_sub2, html)
return html2 return html2
if re.search("https://www.mbank.com.pl/ib_navibar_3.asp", url): if mbank.search(url):
html2 = re.sub("<td valign=\"top\"><img", "<tr><td valign=\"top\"><img", html) html2 = re.sub(mbank_sub1, mbank_sub2, html)
return html2 return html2
return None return None