大佬教程收集整理的这篇文章主要介绍了如何使用硒从网页上下载嵌入式PDF?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在这里,用代码描述:
= ^ .. ^ =
from SELEnium import webdriver
import os
# initialise browser
browser = webdriver.Chrome(os.getcwd()+'/Chromedriver')
# load page with iframe
browser.get('https://www.sebi.gov.in/enforcement/orders/jun-2019/adjuDication-order-in-respect-of-three-entitIEs-in-the-matter-of-prism-meDico-and-pharmacy-ltd-_43323.HTML')
# find pdf url
pdf_url = browser.find_elemenT_By_tag_name('iframe').get_attribute("src")
# load page with pdf
browser.get(pdf_url)
# download file
download = browser.find_elemenT_By_xpath('//*[@ID="download"]')
download.click()
我想使用硒从网页上下载嵌入式PDF,就像这张图片一样。 嵌入式PDF图像
例如,这样的页面:https :
//www.sebi.gov.in/enforcement/orders/jun-2019/adjuDication-order-in-respect-
of-three-entities-in-the-matter-of-prism -meDico-and-pharmacy-
ltd-_43323.html
我尝试了下面提到的代码,但没有成功。
def download_pdf(lnk):
from SELEnium import webdriver
from time import sleep
options = webdriver.ChromeOptions()
download_folder = "/*My folder*/"
profile = {"plugins.plugins_list": [{"enabled": false,"name": "Chrome PDF Viewer"}],"download.default_directory": download_folder,"download.extensions_to_open": ""}
options.add_experimental_option("prefs",profilE)
print("Downloading file from link: {}".format(lnk))
driver = webdriver.Chrome('/*Path of chromedriver*/',chrome_options = options)
driver.get(lnk)
imp_by1 = driver.find_elemenT_By_id("secondaryToolbarToggle")
imp_by1.click()
imp_by = driver.find_elemenT_By_id("secondaryDownload")
imp_by.click()
print("Status: Download Complete.")
driver.close()
download_pdf('https://www.sebi.gov.in/enforcement/orders/jun-2019/adjuDication-order-in-respect-of-three-entities-in-the-matter-of-prism-meDico-and-pharmacy-ltd-_43323.html')
任何帮助表示赞赏。
提前致谢!!
以上是大佬教程为你收集整理的如何使用硒从网页上下载嵌入式PDF?全部内容,希望文章能够帮你解决如何使用硒从网页上下载嵌入式PDF?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。