Python - Selenium - 打印网页

Pho*_*nix 5 html python printing selenium python-3.x

请问如何使用 Selenium 打印网页。

import time
from selenium import webdriver

# Initialise the webdriver
chromeOps=webdriver.ChromeOptions()
chromeOps._binary_location = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
chromeOps._arguments = ["--enable-internal-flash"]
browser = webdriver.Chrome("C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe", port=4445, chrome_options=chromeOps)
time.sleep(3)

# Login to Webpage
browser.get('www.webpage.com')
Run Code Online (Sandbox Code Playgroud)

注意:我目前使用的是当前版本的 Google Chrome:版本 32.0.1700.107 m

Tet*_*ity 3

虽然它不是直接打印网页,但很容易截取整个当前页面的屏幕截图:

browser.save_screenshot("screenshot.png")
Run Code Online (Sandbox Code Playgroud)

然后可以使用任何图像打印库打印图像。我个人没有使用过任何这样的库,所以我不能保证它,但快速搜索发现了win32print,它看起来很有前途。