Skip to content

Instantly share code, notes, and snippets.

@Techcable
Created July 24, 2025 21:15
Show Gist options
  • Save Techcable/c1ac7e8376e2cc39f73d8e5ece4b3d7f to your computer and use it in GitHub Desktop.
Save Techcable/c1ac7e8376e2cc39f73d8e5ece4b3d7f to your computer and use it in GitHub Desktop.
A small script to join URLs against a base path
#!/usr/bin/env python3
"""A command line interface to urllib.parse.urljoin"""
import argparse
from urllib.parse import urljoin
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("base", help="The base URL")
parser.add_argument("urls", help="The URLs to join against the base", nargs="+")
args = parser.parse_args()
for u in args.urls:
print(urljoin(args.base, u))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment