mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[python] Sample google redirect
This commit is contained in:
parent
87eef617a6
commit
5169f78a4a
@ -24,6 +24,7 @@ quit_hook() -- Clean up before ELinks exits.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import elinks
|
import elinks
|
||||||
|
from urllib.parse import urlparse, parse_qs
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
|
|
||||||
dumbprefixes = {
|
dumbprefixes = {
|
||||||
@ -74,9 +75,12 @@ def follow_url_hook(url):
|
|||||||
url -- The URL of the link.
|
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):
|
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):
|
def pre_format_html_hook(url, html):
|
||||||
"""Rewrite the body of a document before it's formatted.
|
"""Rewrite the body of a document before it's formatted.
|
||||||
|
Loading…
Reference in New Issue
Block a user