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

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

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.

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/

Thank you @Anders 2.

Thank you @Vegaseat.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.