久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='epMFv'><tr id='epMFv'><dt id='epMFv'><q id='epMFv'><span id='epMFv'><b id='epMFv'><form id='epMFv'><ins id='epMFv'></ins><ul id='epMFv'></ul><sub id='epMFv'></sub></form><legend id='epMFv'></legend><bdo id='epMFv'><pre id='epMFv'><center id='epMFv'></center></pre></bdo></b><th id='epMFv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='epMFv'><tfoot id='epMFv'></tfoot><dl id='epMFv'><fieldset id='epMFv'></fieldset></dl></div>
      1. <tfoot id='epMFv'></tfoot>

        <legend id='epMFv'><style id='epMFv'><dir id='epMFv'><q id='epMFv'></q></dir></style></legend>

        <small id='epMFv'></small><noframes id='epMFv'>

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

        如何在 Selenium (Python) 中將打開的頁面保存為 pd

        how to save opened page as pdf in Selenium (Python)(如何在 Selenium (Python) 中將打開的頁面保存為 pdf)

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

              • <bdo id='5JNtP'></bdo><ul id='5JNtP'></ul>

                  <tbody id='5JNtP'></tbody>
              • <legend id='5JNtP'><style id='5JNtP'><dir id='5JNtP'><q id='5JNtP'></q></dir></style></legend>

              • <tfoot id='5JNtP'></tfoot>

                <small id='5JNtP'></small><noframes id='5JNtP'>

                  本文介紹了如何在 Selenium (Python) 中將打開的頁面保存為 pdf的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我已經(jīng)嘗試了所有可以在 Internet 上找到的解決方案,以便能夠在 Python 中打印在 Selenium 中打開的頁面.但是,當(dāng)打印彈出窗口出現(xiàn)時,一兩秒后它消失了,沒有保存任何 PDF.

                  Have tried all the solutions I could find on the Internet to be able to print a page that is open in Selenium in Python. However, while the print pop-up shows up, after a second or two it goes away, with no PDF saved.

                  這是正在嘗試的代碼.基于此處的代碼 - https://stackoverflow.com/a/43752129/3973491

                  Here is the code being tried. Based on the code here - https://stackoverflow.com/a/43752129/3973491

                  使用 Mojave 10.14.5 在 Mac 上編碼.

                  Coding on a Mac with Mojave 10.14.5.

                  from selenium import webdriver
                  from selenium.webdriver.support.select import Select
                  from selenium.webdriver.common.by import By
                  from selenium.webdriver.support.ui import WebDriverWait
                  from selenium.webdriver.support import expected_conditions as EC
                  from selenium.common.exceptions import NoSuchElementException
                  from selenium.common.exceptions import TimeoutException
                  from selenium.webdriver.chrome.options import Options
                  from selenium.common.exceptions import WebDriverException
                  import time
                  import json
                  
                  options = Options()
                  appState = {
                      "recentDestinations": [
                          {
                              "id": "Save as PDF",
                              "origin": "local"
                          }
                      ],
                      "selectedDestinationId": "Save as PDF",
                      "version": 2
                  }
                  
                  profile = {'printing.print_preview_sticky_settings.appState': json.dumps(appState)}
                  # profile = {'printing.print_preview_sticky_settings.appState':json.dumps(appState),'savefile.default_directory':downloadPath}
                  options.add_experimental_option('prefs', profile)
                  options.add_argument('--kiosk-printing')
                  CHROMEDRIVER_PATH = '/usr/local/bin/chromedriver'
                  
                  driver = webdriver.Chrome(options=options, executable_path=CHROMEDRIVER_PATH)
                  driver.implicitly_wait(5)
                  driver.get(url)
                  driver.execute_script('window.print();')
                  

                  $chromedriver --v
                  ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003})
                  

                  關(guān)于如何將打開的 html 頁面打印為 PDF 的任何提示或解決方案.花了幾個小時試圖完成這項工作.謝謝!

                  Any hints or solutions as to what can be done to print the open html page to a PDF. Have spent hours trying to make this work. Thank you!

                  2019-07-11 更新:

                  Update on 2019-07-11:

                  我的問題已被確定為重復(fù),但是 a) 另一個問題似乎是使用 javascript 代碼,并且 b) 答案不能解決這個問題中提出的問題 - 這可能與更新的軟件有關(guān)版本.正在使用的 Chrome 版本是版本 75.0.3770.100 (Official Build) (64-bit),chromedriver 是 ChromeDriver 75.0.3770.90.在 Mac OS Mojave 上.腳本在 Python 3.7.3 上運行.

                  My question has been identified as a duplicate, but a) the other question seems to be using javascript code, and b) the answer does not solve the problem being raised in this question - it may be to do with more recent software versions. Chrome version being used is Version 75.0.3770.100 (Official Build) (64-bit), and chromedriver is ChromeDriver 75.0.3770.90. On Mac OS Mojave. Script is running on Python 3.7.3.

                  2019-07-11 更新:

                  Update on 2019-07-11:

                  把代碼改成

                  from selenium import webdriver
                  import json
                  
                  chrome_options = webdriver.ChromeOptions()
                  settings = {
                      "appState": {
                          "recentDestinations": [{
                              "id": "Save as PDF",
                              "origin": "local",
                              "account": "",
                          }],
                          "selectedDestinationId": "Save as PDF",
                          "version": 2
                      }
                  }
                  prefs = {'printing.print_preview_sticky_settings': json.dumps(settings)}
                  chrome_options.add_experimental_option('prefs', prefs)
                  chrome_options.add_argument('--kiosk-printing')
                  CHROMEDRIVER_PATH = '/usr/local/bin/chromedriver'
                  driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=CHROMEDRIVER_PATH)
                  driver.get("https://google.com")
                  driver.execute_script('window.print();')
                  driver.quit()
                  

                  而現(xiàn)在,什么也沒有發(fā)生.Chrome 啟動,加載 url,出現(xiàn)打印對話框,但似乎什么都沒有發(fā)生 - 默認(rèn)打印機隊列中沒有任何內(nèi)容,也沒有 pdf - 我什至通過在 Mac 上查找最近的文件"來搜索 PDF 文件.

                  And now, nothing happens. Chrome launches, loads url, print dialog appears but then nothing seems to happen - nothing in the default printer queue, and no pdf either - I even searched for the PDF files by looking up "Recent Files" on Mac.

                  推薦答案

                  答案 這里,當(dāng)我的操作系統(tǒng)中沒有任何其他打印機設(shè)置時工作.但是當(dāng)我有另一個默認(rèn)打印機時,這不起作用.

                  The answer here, worked when I did not have any other printer setup in my OS. But when I had another default printer, this did not work.

                  我不明白怎么做,但是以這種方式進(jìn)行小的更改似乎可行.

                  I don't understand how, but making small change this way seems to work.

                  from selenium import webdriver
                  import json
                  
                  chrome_options = webdriver.ChromeOptions()
                  settings = {
                         "recentDestinations": [{
                              "id": "Save as PDF",
                              "origin": "local",
                              "account": "",
                          }],
                          "selectedDestinationId": "Save as PDF",
                          "version": 2
                      }
                  prefs = {'printing.print_preview_sticky_settings.appState': json.dumps(settings)}
                  chrome_options.add_experimental_option('prefs', prefs)
                  chrome_options.add_argument('--kiosk-printing')
                  CHROMEDRIVER_PATH = '/usr/local/bin/chromedriver'
                  driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=CHROMEDRIVER_PATH)
                  driver.get("https://google.com")
                  driver.execute_script('window.print();')
                  driver.quit()
                  

                  這篇關(guān)于如何在 Selenium (Python) 中將打開的頁面保存為 pdf的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                  <i id='5XrY5'><tr id='5XrY5'><dt id='5XrY5'><q id='5XrY5'><span id='5XrY5'><b id='5XrY5'><form id='5XrY5'><ins id='5XrY5'></ins><ul id='5XrY5'></ul><sub id='5XrY5'></sub></form><legend id='5XrY5'></legend><bdo id='5XrY5'><pre id='5XrY5'><center id='5XrY5'></center></pre></bdo></b><th id='5XrY5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5XrY5'><tfoot id='5XrY5'></tfoot><dl id='5XrY5'><fieldset id='5XrY5'></fieldset></dl></div>

                  <tfoot id='5XrY5'></tfoot>

                    <legend id='5XrY5'><style id='5XrY5'><dir id='5XrY5'><q id='5XrY5'></q></dir></style></legend>
                        <tbody id='5XrY5'></tbody>

                            <bdo id='5XrY5'></bdo><ul id='5XrY5'></ul>
                          • <small id='5XrY5'></small><noframes id='5XrY5'>

                          • 主站蜘蛛池模板: 久久99国产精一区二区三区 | 国产精品乱码一二三区的特点 | 欧美一区二区三区视频 | 国产精品视频在线观看 | 中文字幕在线不卡 | 精品日韩一区二区三区av动图 | 久久精品国产久精国产 | 国产一区视频在线 | 欧美成人激情 | 一级毛片色一级 | 国产精品一区二区视频 | 欧美成人一区二区三区 | 日日摸夜夜爽人人添av | 99精品久久久久久 | 91色在线视频 | 999精品视频| av在线一区二区 | 欧美黑人国产人伦爽爽爽 | 亚洲91精品 | 伊人伊人伊人 | 亚洲aⅴ| 青青久在线视频 | 国产69精品久久99不卡免费版 | 最新黄色在线观看 | 1000部精品久久久久久久久 | 美女在线视频一区二区三区 | 国产激情一区二区三区 | 日韩2020狼一二三 | 欧美日韩高清在线一区 | 久久久久久网站 | 欧美综合久久久 | 欧美精品久久久久 | 国产精品一区二区不卡 | 欧美中文字幕在线观看 | 玖玖在线精品 | 日韩二区三区 | 美女福利视频一区 | 国产在线视频一区 | 99久热| 麻豆天堂 | 91亚洲国产成人久久精品网站 |