Build a URL using Python requests library -
i have base url.
base_url = 'https://api.github.com/licenses'
i want create new url based on search term(ex - mit) appended base url.
new_url = 'https://api.github.com/licenses/mit'
i using requests library build , call urls 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 print new_url, messes url.
https://api.github.com/mit
i not sure how fix issue.
add /
@ end of base url.
base_url = 'https://api.github.com/licenses/'
otherwise it's treating licences filename.
Comments
Post a Comment