urllib.parse.urljoin()
urllib.parse.urljoin() is a Python function in the Urllib Module category. Constructs a full URL by combining a base URL with a relative URL. The syntax is urllib.parse.urljoin(base, url, allow_fragments=True). Returns: Absolute URL string. A typical example: from urllib.parse import urljoin
urljoin("https://example.com/docs/", "guide.html")
# "https://example.com/docs/guide.html". A close sibling is urllib.request.urlopen(), which opens a URL for reading (like GET request). Returns a file-like response object. A close sibling is urllib.request.Request(), which creates an HTTP request with custom headers and method. A close sibling is urllib.parse.urlparse(), which parses a URL into its components (scheme, netloc, path, params, query, fragment). A close sibling is urllib.parse.urlencode(), which encodes dictionary or sequence of pairs into a URL query string. More about this category: URL handling — request, parse, urlopen, urlparse, urlencode, quote. Related Urllib Module entries: urllib.request.urlopen(), urllib.request.Request(), urllib.parse.urlparse(), urllib.parse.urlencode(), urllib.parse.quote(), urllib.parse.unquote(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.