大佬教程收集整理的这篇文章主要介绍了使用Selenium Python ChromeDriver从弹出窗口/表单下载PDF,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
请尝试以下方法:
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()
更新:要退出弹出窗口,可以尝试以下操作:
driver.switch_to.default_content()
driver.find_elemenT_By_xpath('//*[@ID="ctl00_GenericPopupSizeable_InnerPopupControl_HCB-1"]/img').click()
无法确定下一步,尝试从网站下载pdf文件并被卡住。
“
https://www.southtechhosTing.com/SanJoseCity/CampaignDocsWebRetrieval/Search/SearchByElection.aspx
”
带有PDF文件链接的页面
PDF文件下载
我可以使用SELEnium和ChromeDriver从“带有链接的页面”中单击pdf链接,但是随后我得到了一个弹出表单而不是下载。
我尝试禁用Chrome PDF查看器(“ plugins.plugins_list”:[{“ enabled”:false,“ name”:“ Chrome
PDF Viewer”}]),但这无法正常工作。
弹出表单(在“要下载的PDF文件”中查看)具有一个悬停链接,用于下载pdf文件。我已经尝试过ActionChains(),但是在运行以下代码后却遇到了这个异常:
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()
寻找在这种情况下下载pdf文件的最有效方法。谢谢!
以上是大佬教程为你收集整理的使用Selenium Python ChromeDriver从弹出窗口/表单下载PDF全部内容,希望文章能够帮你解决使用Selenium Python ChromeDriver从弹出窗口/表单下载PDF所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。