Hi everybody.
What is the usage of urljoin?
An example:

>>> from urlparse import urljoin
>>> url = urljoin('http://python.org/','about.html')
>>> url

I think the answer is that when we take a link from here 'http://www.python.org/ for example , it looks like this <a href="/about/>about</a>.
So if i take the href part which is /about/ here and use urljoin to join this string (of course with .html) to the main url which is 'http://python.org/' here. Correct?!

Of course i should delete those / and / from /about/ first.

Edited 1 Year Ago by Niloofar24

It's a function from standard module urlparse in Python2. You will find mor info and syntax in python docs at the official site Python.org.

Follow link -> Click Here

An example ...

# assume you have this url ...
url = "https://www.python.org/downloads/release/python-343/"
# the base (scheme + netloc) would be ...
base = "https://www.python.org/"
# the path would be ...
path = "downloads/release/python-343/"
# however you want to select one of these paths ...
path_list = ["community/", "doc/", "community/jobs/"]

# to create a full url use ...
new_url = urlparse.urljoin(base, path_list[2])
print(new_url)  # https://www.python.org/community/jobs/ 
This question has already been answered. Start a new discussion instead.