What do I need to do? I need to download an excel in a specific route through my python code which I use selenium and chrome driver.
What happens? Downloading the file well without hiding or putting it in the background does not work and does not report any errors.
My code:
# -*- coding: utf-8 -*-
# Autor: Diego Lopez
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import sys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = "********************"
#browser = webdriver.PhantomJS("C:/Users/DIEGO/Documents/diego/scraping/phantomjs.exe")
download_dir = 'C:/Users/DIEGO/Documents/diego/scraping/'
chrome_profile = webdriver.ChromeOptions()#1
profile = {"download.default_directory": download_dir,
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": False,
"safebrowsing.disable_download_protection": False,
"plugins.always_open_pdf_externally": True}#2
chrome_profile.add_experimental_option("prefs", profile)#3
chrome_profile.add_argument("--disable-extensions")#4
chrome_profile.add_argument("--disable-print-preview")#5
chrome_profile.add_argument("--disable-infobars")
chrome_profile.add_argument('--headless')
#chrome_profile.add_argument('window-size=1200x600')
driver = webdriver.Chrome(chrome_options=chrome_profile)#6
#try:
driver.get(url)
driver.maximize_window()
driver.execute_script("document.getElementById('ctl14_btnLogOn').click();")
print('Desgargando ... .. ')
time.sleep(5)
driver.save_screenshot('pruebaF.png')
driver.quit()
What could I do to solve this?