I wish to have my Python script download the Master data (Download, XLSX) Excel file from this Frankfurt stock exchange webpage.
When to retrieve it with
from bs4 import BeautifulSoup
import requests
import re
url='http://www.xetra.com/xetra-en/instruments/etf-exchange-traded-funds/list-of-tradable-etfs'
html=requests.get(url)
page=BeautifulSoup(html.content)
reg=re.compile('Master data')
find=page.find('span',text=reg) #find the file url
file_url='http://www.xetra.com'+find.parent['href']
file=requests.get(file_url)
with open(r'C:\\Users\user\Downloads\file.xlsx','wb') as ff:
ff.write(file.content)
recommend requests and BeautifulSoup,both good lib