【问题标题】:Problem download pdf files with python + selenium使用 python + selenium 下载 pdf 文件的问题
【发布时间】:2020-06-25 16:32:46
【问题描述】:

我需要你的帮助,我正在尝试在 python 中使用 selenium webdriver 自动下载 PDF 文件,执行此代码时会为我带来下载链接并在控制台中打印它们,但我需要将它们下载并保存在本地个人电脑。

我在 python 3x 中使用 ubuntu 18.04 作为开发环境。 谢谢

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)

【问题讨论】:

    标签: python-3.x selenium-webdriver


    【解决方案1】:

    有很多关于同一问题的帖子。

    在这个(Selenium Webdriver in Python - files download directory change in Chrome preferences) 中,有一个修复,您可以更改默认下载位置。

    另外,请记住,您可能需要执行一个例程来等待下载完成(如果您正在下载大文件)。

    希望对你有帮助。

    【讨论】:

    • 非常感谢您的回答,它们不是那么大的文件,但仍然非常感谢您的回答,我会审查它。谢谢
    猜你喜欢
    • 1970-01-01
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 2018-11-13
    • 2020-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多