Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence =?iso-8859-13?q?D=FFOliveiro?= Newsgroups: comp.lang.python,alt.comp.software.firefox Subject: Re: No more Redirect page. Date: Sat, 25 Jul 2026 04:33:42 -0000 (UTC) Organization: A noiseless patient Spider Lines: 71 Message-ID: <1141eb5$16llq$1@dont-email.me> References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 25 Jul 2026 04:33:42 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1267386"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+f+bs6JxFktRZ9cGUSZeO"; posting-host="72e9fbc853ff8a3ddd302a9e1c6c29af" User-Agent: Pan/0.165 (Kostiantynivka) Cancel-Lock: sha1:ZyjSLvLdncBRmkJZDHV38SbxiEQ= sha256:8GO6DNqp64eZMhiWtMz2SkoYneaOrFbOggFD3dfEiUg= sha1:YKS9gulFUSn3a80akEjCTPPPu1c= sha256:wUzwSATwUvmS72rUve9UBksvp1yu7y2+zqf79VOfo3A= Xref: csiph.com comp.lang.python:197825 alt.comp.software.firefox:17907 On Fri, 24 Jul 2026 11:03:09 -0400, micky wrote: > You may have noticed by now that clicking on Google search links > sometimes or always makes you stop at a page to "permit" redirection > to another page, even though you clicked on it in the first place > and even though it never did this before. "The "redirect notice" > page usually appears because Google wraps outbound links with a > tracking parameter (google.com/url) to gather analytics and scan for > malicious URLs". I often copy and paste links into the following script for this reason. Feel free to experiment with this as appropriate. Note the “--unquote” option, because sometimes I find the wrapped URL has an extra (needless) level of quoting. ---- #!/usr/bin/python3 #+ # Given a URL from various sites that like to include redirection # capture cruft, extract the URL and discard the cruft. #- import sys import re from urllib import \ parse as urlparse import getopt start_marker = r"\=(https?(\:\/\/|\%3a\%2f\%2f))" show_original = False force_unquote = False opts, args = getopt.getopt \ ( sys.argv[1:], "", ["original", "unquote"] ) for keyword, value in opts : if keyword == "--original" : show_original = True elif keyword == "--unquote" : force_unquote = True #end if #end for urls = args if len(urls) == 0 : raise getopt.GetoptError("pass at least one URL to unredirect") #end if for url in urls : matches = list(re.compile(start_marker, re.IGNORECASE).finditer(url)) if len(matches) != 0 : match = matches[-1] startpos = match.start(1) endpos = url.find("&", match.end(1)) if endpos < 0 : endpos = len(url) #end if actual = url[startpos : endpos] if match.group(2).startswith("%") or force_unquote : actual = urlparse.unquote(actual) #end if if show_original : sys.stdout.write("%s => " % url) #end if sys.stdout.write("%s\n" % actual) else : sys.stdout.write("# Cannot understand: %s\n" % url) #end if #end for