<i id='U9ETY'><tr id='U9ETY'><dt id='U9ETY'><q id='U9ETY'><span id='U9ETY'><b id='U9ETY'><form id='U9ETY'><ins id='U9ETY'></ins><ul id='U9ETY'></ul><sub id='U9ETY'></sub></form><legend id='U9ETY'></legend><bdo id='U9ETY'><pre id='U9ETY'><center id='U9ETY'></center></pre></bdo></b><th id='U9ETY'></th></span></q></dt></tr></i><div id='U9ETY'><tfoot id='U9ETY'></tfoot><dl id='U9ETY'><fieldset id='U9ETY'></fieldset></dl></div>
  1. <small id='U9ETY'></small><noframes id='U9ETY'>

  2. <tfoot id='U9ETY'></tfoot>
  3. <legend id='U9ETY'><style id='U9ETY'><dir id='U9ETY'><q id='U9ETY'></q></dir></style></legend>

        <bdo id='U9ETY'></bdo><ul id='U9ETY'></ul>

      使用 Selenium Python ChromeDriver 从弹出窗口/表单下载 PDF

      时间:2023-07-05
        <tbody id='m7vF0'></tbody>
        • <legend id='m7vF0'><style id='m7vF0'><dir id='m7vF0'><q id='m7vF0'></q></dir></style></legend>
            <bdo id='m7vF0'></bdo><ul id='m7vF0'></ul>

            1. <small id='m7vF0'></small><noframes id='m7vF0'>

              <i id='m7vF0'><tr id='m7vF0'><dt id='m7vF0'><q id='m7vF0'><span id='m7vF0'><b id='m7vF0'><form id='m7vF0'><ins id='m7vF0'></ins><ul id='m7vF0'></ul><sub id='m7vF0'></sub></form><legend id='m7vF0'></legend><bdo id='m7vF0'><pre id='m7vF0'><center id='m7vF0'></center></pre></bdo></b><th id='m7vF0'></th></span></q></dt></tr></i><div id='m7vF0'><tfoot id='m7vF0'></tfoot><dl id='m7vF0'><fieldset id='m7vF0'></fieldset></dl></div>

                <tfoot id='m7vF0'></tfoot>
                本文介绍了使用 Selenium Python ChromeDriver 从弹出窗口/表单下载 PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                无法确定下一步,尝试从网站下载 pdf 文件并卡住.

                "

                寻找在这种情况下下载 pdf 文件的最有效方法.谢谢!

                解决方案

                请试试这个:

                chromeOptions = webdriver.ChromeOptions()prefs = {"plugins.always_open_pdf_externally": True}chromeOptions.add_experimental_option("prefs",prefs)驱动程序 = webdriver.Chrome(chrome_options=chromeOptions)driver.get('https://www.southtechhosting.com/SanJoseCity/CampaignDocsWebRetrieval/Search/SearchByElection.aspx')#打开弹窗的代码driver.find_element_by_xpath('//*[@id="ctl00_DefaultContent_ASPxRoundPanel1_btnFindFilers_CD"]').click()driver.find_element_by_xpath('//*[@id="ctl00_GridContent_gridFilers_DXCBtn0"]').click()driver.find_element_by_xpath('//*[@id="ctl00_DefaultContent_gridFilingForms_DXCBtn0"]').click()driver.switch_to.frame(driver.find_element_by_tag_name('iframe'))a = driver.find_element_by_link_text("点击这里")ActionChains(driver).key_down(Keys.CONTROL).click(a).key_up(Keys.CONTROL).perform()

                更新:要退出弹出窗口,您可以尝试以下操作:

                driver.switch_to.default_content()driver.find_element_by_xpath('//*[@id="ctl00_GenericPopupSizeable_InnerPopupControl_HCB-1"]/img').click()

                Having trouble figuring out the next step, trying to download a pdf file from a website and getting stuck.

                "https://www.southtechhosting.com/SanJoseCity/CampaignDocsWebRetrieval/Search/SearchByElection.aspx"

                Page with Links to PDF Files

                PDF file to download

                I was able to click on the pdf link from the "Page with Links" using Selenium & ChromeDriver but then I get a popup form instead of a download.

                I tried disabling the Chrome PDF Viewer ("plugins.plugins_list":[{"enabled":False,"name":"Chrome PDF Viewer"}]), but that doesn't work.

                The popup form (viewed in "PDF file to download") has a hover link to download the pdf file. I've tried ActionChains(), but I get this exception after running this line:

                from selenium.webdriver.common.action_chains import ActionChains
                
                element_to_hover = driver.find_element_by_xpath("//paper-icon-button[@id='download']")
                hover = ActionChains(driver).move_to_element(element_to_hover)
                hover.perform()
                

                Looking for the most efficient way to download pdf files in this type of situation. Thanks!

                解决方案

                Please try this:

                chromeOptions = webdriver.ChromeOptions()
                prefs = {"plugins.always_open_pdf_externally": True}
                chromeOptions.add_experimental_option("prefs",prefs)
                driver = webdriver.Chrome(chrome_options=chromeOptions)
                driver.get('https://www.southtechhosting.com/SanJoseCity/CampaignDocsWebRetrieval/Search/SearchByElection.aspx')
                
                #Code to open the pop-up
                driver.find_element_by_xpath('//*[@id="ctl00_DefaultContent_ASPxRoundPanel1_btnFindFilers_CD"]').click()
                driver.find_element_by_xpath('//*[@id="ctl00_GridContent_gridFilers_DXCBtn0"]').click()
                driver.find_element_by_xpath('//*[@id="ctl00_DefaultContent_gridFilingForms_DXCBtn0"]').click()
                
                driver.switch_to.frame(driver.find_element_by_tag_name('iframe'))
                a = driver.find_element_by_link_text("Click here")
                ActionChains(driver).key_down(Keys.CONTROL).click(a).key_up(Keys.CONTROL).perform()
                

                UPDATE: To exit the popup, you can try this:

                driver.switch_to.default_content()
                driver.find_element_by_xpath('//*[@id="ctl00_GenericPopupSizeable_InnerPopupControl_HCB-1"]/img').click()
                

                这篇关于使用 Selenium Python ChromeDriver 从弹出窗口/表单下载 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:使用 Python 向联系人发送 whatsapp 消息但收到错误:InvalidSelectorException: 下一篇:如何重用 selenium 浏览器会话

                相关文章

                  <legend id='Z7GVc'><style id='Z7GVc'><dir id='Z7GVc'><q id='Z7GVc'></q></dir></style></legend>
                1. <tfoot id='Z7GVc'></tfoot>

                  <i id='Z7GVc'><tr id='Z7GVc'><dt id='Z7GVc'><q id='Z7GVc'><span id='Z7GVc'><b id='Z7GVc'><form id='Z7GVc'><ins id='Z7GVc'></ins><ul id='Z7GVc'></ul><sub id='Z7GVc'></sub></form><legend id='Z7GVc'></legend><bdo id='Z7GVc'><pre id='Z7GVc'><center id='Z7GVc'></center></pre></bdo></b><th id='Z7GVc'></th></span></q></dt></tr></i><div id='Z7GVc'><tfoot id='Z7GVc'></tfoot><dl id='Z7GVc'><fieldset id='Z7GVc'></fieldset></dl></div>
                2. <small id='Z7GVc'></small><noframes id='Z7GVc'>

                    <bdo id='Z7GVc'></bdo><ul id='Z7GVc'></ul>