37,744
社区成员
发帖
与我相关
我的任务
分享
import json
from selenium import webdriver
driver = webdriver.Chrome()
resource = "/session/%s/chromium/send_command_and_get_result" % driver.session_id
url = driver.command_executor._url + resource
body = json.dumps({'cmd': 'Page.printToPDF', 'params': {
'landscape': False,
'displayHeaderFooter': False,
'printBackground': True,
'preferCSSPageSize': True,
}})
response = driver.command_executor._request('POST', url, body)
result = response.get('value')
with open('report.pdf', 'wb') as file:
file.write(result)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
import pyautogui
from selenium import webdriver
re = webdriver.Chrome()
re.get('https://www.baidu.com')
pyautogui.hotkey('ctrl', 'p')
time.sleep(2)
re.quit()