1

I wish to have Firefox using selenium for Python to download the Master data (Download, XLSX) Excel file from this Frankfurt stock exchange webpage.

The problem: I can't get Firefox to download the file without asking where to save it first.

Let me first point out that the URL I'm trying to get the Excel file from, is really a Blob URL:

http://www.xetra.com/blob/1193366/b2f210876702b8e08e40b8ecb769a02e/data/All-tradable-ETFs-ETCs-and-ETNs.xlsx

Perhaps the Blob is causing my problem? Or, perhaps the problem is in my MIME handling?

from selenium import webdriver

profile_dir = "path/to/ff_profile"
dl_dir = "path/to/dl/folder"

ff_profile = webdriver.FirefoxProfile(profile_dir)

ff_profile.set_preference("browser.download.folderList", 2)
ff_profile.set_preference("browser.download.manager.showWhenStarting", False)
ff_profile.set_preference("browser.download.dir", dl_dir)
ff_profile.set_preference('browser.helperApps.neverAsk.saveToDisk', "text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream")

driver = webdriver.Firefox(ff_profile)

url = "http://www.xetra.com/xetra-en/instruments/etf-exchange-traded-funds/list-of-tradable-etfs"
driver.get(url)

dl_link = driver.find_element_by_partial_link_text("Master data")
dl_link.click()
P A N
  • 5,642
  • 15
  • 52
  • 103

1 Answers1

1

The actual mime-type to be used in this case is:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

How do I know that? Here is what I've done:

  • opened Firefox manually and navigated to the target site
  • when downloading the file, checked the checkbox to save these kind of files automatically
  • went to Help -> Troubleshooting Information and navigated to the "Profile Folder"
  • in the profile folder, foudn and opened mimetypes.rdf
  • inside the mimetypes.rdf found the record/resource corresponding to the excel file I've recently downloaded
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Thanks Alex for the answer and those guidelines. This [answer](http://stackoverflow.com/a/4212908/4909923) seems to be useful too. – P A N Sep 15 '16 at 20:15