selenium-chrome-headless 模式
code
import sys,os sys.path.append("/".join(os.path.dirname(os.path.abspath(__file__)).split("/")[:-1])+'/lib') from selenium import webdriver import time from selenium.webdriver.common.keys import Keys def asleep(driver): driver.implicitly_wait(3.5) time.sleep(2) ''' chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('headless') driver = webdriver.Chrome(options=chrome_options) ''' driver = webdriver.Chrome() asleep(driver) driver.get("http://prodjixieweb.1111-111.com/#/login") driver.maximize_window() driver.find_element_by_xpath(".//div[@class='login-container-r']/div[2]/input").send_keys("abc") driver.find_element_by_xpath(".//div[@class='login-container-r']/div[3]/input").send_keys("icloudeep123") driver.find_element_by_xpath(".//div[@class='login-container-r']/div[4]/input").send_keys("12345") driver.find_element_by_xpath(".//div[@class='login-container-r']/div[6]").click() asleep(driver) detail_url="http://prodjixieweb.1111-111.com/#/contractDetail?contractNum=20200701141255633CT466363" driver.get(detail_url) asleep(driver) driver.find_element_by_xpath(".//div[@class='float-left column list-r']/div[4]/div[2]/span").click() asleep(driver) js = "var q=document.body.scrollTop=10000" driver.execute_script(js) asleep(driver) driver.save_screenshot('capture.png')