I have a base URL.
BASE_URL = 'https://api.github.com/licenses'
I want to create a new url based on a search term(Ex - mit) appended to the base URL.
NEW_URL = 'https://api.github.com/licenses/mit'
I am using requests library to build and call the URLs as shown below.
from requests.compat import urljoin
base_url = 'https://api.github.com/licenses'
new_url = urljoin(base_url, 'mit')
print new_url
But when I print the new_url, it messes up the URL.
https://api.github.com/mit
I am not sure how to fix this issue.
Add a /
at the end of the base url.
BASE_URL = 'https://api.github.com/licenses/'
Otherwise it's probably treating licences as filename.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With