1

I need your help, I am trying to automate the download of PDF files with selenium webdriver in python, this code when executed brings me the download links and prints them in console but I need them to be downloaded and saved locally in My PC.

I use ubuntu 18.04 as a development environment in python 3x. Thank you

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as W
from selenium.webdriver.support import expected_conditions as E

URL = "https://www.diariooficial.interior.gob.cl/edicionelectronica/marcas_patentes.php?date=19-06-2020&edition=42685"



wait_time_out = 15
driver = webdriver.Chrome('./chromedriver')
driver.get(URL)
wait_variable = W(driver, wait_time_out)
links = wait_variable.until(E.visibility_of_all_elements_located((By.TAG_NAME, "a")))
print("Numero de links", len(links))
for link in links:
    print(link.text)

1 Answers1

2

There are a lot of posts about that same issue.

In this(Selenium Webdriver in Python - files download directory change in Chrome preferences) one, there is a fix, where you change the default download location.

Also, have in mind that you may need to implement a routine to wait for downloads to finish(if you are downloading large files).

Hope it helps.

  • 1
    Thank you very much for your answer, they are not such large files, but still thank you very much for your answer, I will review it. Thank you – cesar rivas Jun 25 '20 at 16:46