Download file from Blob URL with Python

后端 未结 2 1321
死守一世寂寞
死守一世寂寞 2021-01-03 17:33

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

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 17:49

    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

提交回复
热议问题