import os
from urllib.parse import urlparse
url = "http://photographs.500px.com/kyle/09-09-201315-47-571378756077.jpg"
a = urlparse(url)
print(a.path) # Output: /kyle/09-09-201315-47-571378756077.jpg
print(os.path.basename(a.path)) # Output: 09-09-201315-47-571378756077.jpg
url = 'https://www.nobelprize.org/uploads/2021/10/press-physicsprize2021.pdf'
filename = url.split('/')[-1]
## OUTPUT: 'press-physicsprize2021.pdf'