1
0
Fork 0

[python] Sample google redirect

This commit is contained in:
Witold Filipczyk 2020-08-28 12:29:31 +02:00
parent 87eef617a6
commit 5169f78a4a
1 changed files with 6 additions and 2 deletions

View File

@ -24,6 +24,7 @@ quit_hook() -- Clean up before ELinks exits.
"""
import elinks
from urllib.parse import urlparse, parse_qs
from importlib import reload
dumbprefixes = {
@ -74,9 +75,12 @@ def follow_url_hook(url):
url -- The URL of the link.
"""
google_redirect = 'http://www.google.com/url?sa=D&q='
google_redirect = 'https://www.google.com/url?'
if url.startswith(google_redirect):
return url.replace(google_redirect, '')
try:
return parse_qs(urlparse(url).query)['q'][0]
except:
pass
def pre_format_html_hook(url, html):
"""Rewrite the body of a document before it's formatted.