0

I am downloading file from the API URL http://api.worldbank.org/v2/en/topic/19?downloadformat=csv and We get file "API_19_DS2_en_csv_v2_10225248.zip" after hit.

Above URL does not contain "File name" like other URL "http://databank.worldbank.org/data/download/SE4ALL_csv.zip", here I can use ntpath.basename(URL)

How to get file name?

Learnings
  • 2,780
  • 9
  • 35
  • 55
  • may be this helps : https://stackoverflow.com/questions/18885175/read-a-zipped-file-as-a-pandas-dataframe – anky Jan 05 '19 at 06:49

1 Answers1

0

Below code working

r = requests.get(Source_Link)
URL_Metadata = r.headers['Content-Disposition']
Source_File_Name = URL_Metadata[URL_Metadata.find('filename=')+9:]
Learnings
  • 2,780
  • 9
  • 35
  • 55