从d出窗口使用selenium和python下载并保存多个csv文件

从d出窗口使用selenium和python下载并保存多个csv文件,第1张

从d出窗口使用selenium和python下载并保存多个csv文件

这是您问题的答案:

您所说的元素

find_element_by_id("submit-download-list")
实际上是下载
PDF
文件。因此,为了将来程序员和该问题/帖子/线程/讨论的读者的利益,您可以考虑将问题标题更改为
Downloadand Save PDF file using selenium and python from popup

这是从d出窗口使用selenium和python下载和保存PDF文件的代码块:

import osfrom selenium import webdriverfrom selenium.webdriver.firefox.firefox_binary import FirefoxBinaryfrom selenium.webdriver.common.desired_capabilities import DesiredCapabilitiesfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.by import Bybinary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')newpath = 'C:\home\DebanjanB'if not os.path.exists(newpath):    os.makedirs(newpath)profile = webdriver.FirefoxProfile()profile.set_preference("browser.download.dir",newpath)profile.set_preference("browser.download.folderList",2)profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain,text/x-csv,text/csv,application/vnd.ms-excel,application/csv,application/x-csv,text/csv,text/comma-separated-values,text/x-comma-separated-values,text/tab-separated-values,application/pdf")profile.set_preference("browser.download.manager.showWhenStarting",False)profile.set_preference("browser.helperApps.neverAsk.openFile","text/plain,text/x-csv,text/csv,application/vnd.ms-excel,application/csv,application/x-csv,text/csv,text/comma-separated-values,text/x-comma-separated-values,text/tab-separated-values,application/pdf")profile.set_preference("browser.helperApps.alwaysAsk.force", False)profile.set_preference("browser.download.manager.useWindow", False)profile.set_preference("browser.download.manager.focusWhenStarting", False)profile.set_preference("browser.helperApps.neverAsk.openFile", "")profile.set_preference("browser.download.manager.alertOnEXEOpen", False)profile.set_preference("browser.download.manager.showalertOnComplete", False)profile.set_preference("browser.download.manager.closeWhenDone", True)profile.set_preference("pdfjs.disabled", True)caps = DesiredCapabilities.FIREFOXbrowser = webdriver.Firefox(firefox_profile=profile, capabilities=caps, firefox_binary=binary, executable_path='C:\Utility\BrowserDrivers\geckodriver.exe')browser.maximize_window()browser.get("https://clinicaltrials.gov/ct2/results?cond=&term=lomitapide&cntry1=&state1=&SearchAll=Search+all+studies&recrs=")browser.find_element_by_id("save-list-link").click()download_link = WebDriverWait(browser, 10).until(    EC.presence_of_element_located((By.XPATH, "//input[@id='submit-download-list']")))download_link.click()

让我知道这是否回答了您的问题。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5462794.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存