Can You Use Scrapy And Selenium Together Code Example


Example: scrapy selenium screnshot

#coding=utf-8 import time from selenium import webdriver from selenium.webdriver.chrome.options import Options  def test_fullpage_screenshot(self):     chrome_options = Options()     chrome_options.add_argument('--headless')     chrome_options.add_argument('--start-maximized')     driver = webdriver.Chrome(chrome_options=chrome_options)     driver.get("yoururlxxx")     time.sleep(2)      #the element with longest height on page     ele=driver.find_element("xpath", '//div[@class="react-grid-layout layout"]')     total_height = ele.size["height"]+1000      driver.set_window_size(1920, total_height)      #the trick     time.sleep(2)     driver.save_screenshot("screenshot1.png")     driver.quit()  if __name__ == "__main__":     test_fullpage_screenshot()

Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?