get file name from url python

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

Here is what the above code is Doing:
1. urlparse() parses the URL into six components, returning a six-item tuple.
2. The path component is the second item in the tuple.
3. os.path.basename() returns the last component of the path.