【发布时间】:2018-09-11 02:14:29
【问题描述】:
我一直在使用 selenium 自动打印文档,但我卡在了打印屏幕上。据我所知,硒不与打印屏幕交互,所以我正在寻找一种可以与硒一起使用的替代情况。到目前为止,我的代码在下面,我所需要的只是让我选择一台新打印机然后打印的代码。另外,我想将该打印机更改为另存为 PDF,然后将 pdf 保存到文件中,如果这样可以提供一个快捷方式,对我有很大帮助。
from selenium import webdriver
from selenium import *
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.CHROME) #This is because I am using remote web driver for my Mac, but it is the same as regular web driver
driver.execute("window.print()")
#Need code here
【问题讨论】:
标签: python selenium web-scraping printing automation