I am attempting to download an Excel file using its URL, but all I receive is JavaScript code. I'm unsure of how to retrieve the actual file instead of just the JS code.
Here is my current code:
# -*- coding: utf-8 -*-
from selenium import webdriver
import io
import re
path = 'C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe'
download_url = "http://samr.cfda.gov.cn/directory/web/WS01/images/localgov/gov_1540501658076.xls" #URL provided by me
chrome_options = webdriver.ChromeOptions()
#chrome_options.add_argument('--headless') # headless mode to disable GUI for Chrome
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': 'd:\\new'}
chrome_options.add_experimental_option('prefs', prefs)
client = webdriver.Chrome(path, chrome_options=chrome_options)
try:
client.get(download_url)
except TimeoutError:
print("Time took too long")
print(client.page_source)
client.quit()
Any assistance would be greatly appreciated.