Selenium 执行js脚本,截屏
# -*- coding: utf-8 -*- from selenium import webdriver driver = webdriver.Chrome() driver.get('https://www.baidu.com') driver.find_element_by_id('kw').send_keys('美女') driver.find_element_by_id('su').click() js2 = 'window.scrollTo(0,document.body.scrollHeight)' driver.execute_script(js2)
from selenium import webdriver driver = webdriver.Chrome() driver.get('https://www.baidu.com') driver.save_screenshot('s.png') driver.get_screenshot_as_file('ss.png')