Re: No more Redirect page.

Gilmeh Serda <[email protected]> Sat, 25 Jul 2026 15:59:03 GMT
Newsgroups comp.lang.python,alt.comp.software.firefox
Organization Easynews - www.easynews.com
Message-ID <[email protected]>
On Sat, 25 Jul 2026 04:33:42 -0000 (UTC), Lawrence D’Oliveiro wrote:

> I often copy and paste links into the following script for this reason.

Why not use pyperclip? Then you can just use clipboard:

1. Copy original URL
2. Run script (+ options)
3. Paste resulting URL

https://pypi.org/project/pyperclip/

You may also want to read this:
https://github.com/asweigart/pyperclip/blob/master/src/pyperclip/
__init__.py  row 19.


If there are only a few options you might even wanna create an alias for 
each version, like scra and scrb or something and put it in your .bashrc:

    alias scra='scriptname -option1';
    alias scrb='scriptname -option2';

Your use of shebang suggests *nix, so...


If I think ArgumentParser is too bulky for a small script, I usually just 
use sys module, which you already have imported.

def main(opt):
    URL = pyperclip.paste()

    if opt == 1:
	[...]
    elif opt == 2:
        [...]

    pyperclip.copy(resulting_URL)

if __name__ == '__main__':
    args = sys.argv[1:]
    if '-option1' in args:
	main(1)
    elif '-option2' in args:
        main(2)
    else:
        print(usage)

But each to their own... It's your script.

-- 
Gilmeh

Everybody likes a kidder, but nobody lends him money. -- Arthur Miller