driver = webdriver.Chrome() driver.get(url) diver.save_screenshot('保存路徑')
driver = webdriver.Chrome() driver.get(url) #好比得到類名爲img的元素截圖 #首先要等待他加載出來2秒一次 WebDriverWait(driver, 2,1).until(EC.presence_of_element_located((By.CLASS_NAME, 'img'))) #獲取元素保存 img = driver.find_element_by_class_name('img').screenshot('保存路徑'))