Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

take filenames from url python

url = 'https://www.nobelprize.org/uploads/2021/10/press-physicsprize2021.pdf'
filename = url.split('/')[-1]
## OUTPUT: 'press-physicsprize2021.pdf'
Comment

PREVIOUS NEXT
Code Example
Python :: export pandas dataframe as excel 
Python :: python get time of day 
Python :: how to change window size in kivy python 
Python :: youtube dl download mp3 python 
Python :: python border 
Python :: python - convert a column in a dataframe into a list 
Python :: label encoder python 
Python :: save and load catboost model 
Python :: install curses python 
Python :: numpy get index of nan 
Python :: python show interpreter path 
Python :: join video moviepy 
Python :: from string to time python dataframe 
Python :: horizontal line for pyplot 
Python :: plot function in numpy 
Python :: correlation between lists python 
Python :: python add zero to string 
Python :: anaconda-navigator command not found 
Python :: python selenium switch to window 
Python :: open chrome in pyhton 
Python :: sklearn random forest regressor 
Python :: python ftp upload file 
Python :: django created at field 
Python :: python access index in for loop 
Python :: pandas count specific value in column 
Python :: how to save plot in python 
Python :: python Key–value database 
Python :: fill missing values in column pandas with mean 
Python :: matrix pow python 
Python :: cv2 save video mp4 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =