请问如何使用 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')
注意:我目前使用的是 Google Chrome 的当前版本:版本 32.0.1700.107 m
最佳答案
虽然不是直接打印网页,但是很容易对整个当前页面进行截图:
browser.save_screenshot("screenshot.png")
然后可以使用任何图像打印库打印图像。我个人没有使用过任何这样的库,所以我不一定能保证,但快速搜索出现了 win32print这看起来很有希望。
关于Python - Selenium - 打印网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21886101/