Automatically create valid links
Posted
by
Marcos Placona
on Stack Overflow
See other posts from Stack Overflow
or by Marcos Placona
Published on 2011-01-03T19:33:27Z
Indexed on
2011/01/03
19:54 UTC
Read the original article
Hit count: 205
Hi, I'm new to python, so please bare with me :)
I was wondering if there's any built-in way in python to append variables to URL's regardless of it's structure.
I would like to have a URL variable (test=1) added to an URL which could have any of the following structures
http://www.aaa.com (would simply add "/?test=1") to the end
http://www.aaa.com/home (like the one above, would simply add "/?test=1") to the end
http://www.aaa.com/?location=home (would figure out there's already a ? being used, and would add &test=1 to the end)
http://www.aaa.com/?location=home&page=1 (like the one above, would figure out there's already a ? being used, and would add &test=1 to the end)
I'd be happy to write domething to do it myself, but if python can already do it somehow, I'd me more than happy to use any built-in functionality that would save me some time ;-)
Thanks in advance
© Stack Overflow or respective owner