Download file from Blob URL with Python
<p>I wish to have my Python script download the <em>Master data (Download, XLSX)</em> Excel file from this <a href="http://www.xetra.com/xetra-en/instruments/etf-exchange-traded-funds/list-of-tradable-etfs" rel="nofollow">Frankfurt stock exchange webpage</a>.</p>

<p>When to retrieve it with <code>urrlib</code> and <code>wget</code>, it turns out that the URL leads to a <em>Blob</em>  and the file downloaded is only 289 bytes and unreadable.</p>

<blockquote>
  <p><a href="http://www.xetra.com/blob/1193366/b2f210876702b8e08e40b8ecb769a02e/data/All-tradable-ETFs-ETCs-and-ETNs.xlsx" rel="nofollow">http://www.xetra.com/blob/1193366/b2f210876702b8e08e40b8ecb769a02e/data/All-tradable-ETFs-ETCs-and-ETNs.xlsx</a></p>
</blockquote>

<p>I'm entirely unfamiliar with Blobs and have these questions:</p>

<ul>
<li><p>Can the file "behind the Blob" be successfully retrieved using Python?</p></li>
<li><p>If so, is it necessary to uncover the "true" URL behind the Blob â if there is such a thing â and how? My concern here is that the link above won't be static but actually change often.</p></li>
</ul>

<pre><code>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)
</code></pre>

<p>recommend requests and BeautifulSoup,both good lib</p>

python download blob urllib