title: Selenium Screenshot Works Slow (Python)
body: <p>Script with selenium and phantomjs which checks around 20 dynamic pages and warn me when there is a change works fast without screenshot part but when I want to get screenshots of the pages it takes around 1-2 minutes to warn me and to get screenshot. Is there a better and faster way to take screenshot of a specific part of page with python?</p>
  
  <p>Here is the code I use for screenshot.</p>
  
  <pre><code>from selenium import webdriver
  from PIL import Image
  
  fox = webdriver.Firefox()
  fox.get('http://stackoverflow.com/')
  
  # now that we have the preliminary stuff out of the way time to get that image :D
  element = fox.find_element_by_id('hlogo') # find part of the page you want image of
  location = element.location
  size = element.size
  fox.save_screenshot('screenshot.png') # saves screenshot of entire page
  fox.quit()
  
  im = Image.open('screenshot.png') # uses PIL library to open image in memory
  
  left = location['x']
  top = location['y']
  right = location['x'] + size['width']
  bottom = location['y'] + size['height']
  
  
  im = im.crop((left, top, right, bottom)) # defines crop points
  im.save('screenshot.png') # saves new cropped image
  </code></pre>
  
  <blockquote>
    <p>SOLVED:</p>
    
    <p>The problem is not about selenium module, either screenshot. It is
    about phantomjs, after I start using chromedriver it is very fast and more
    efficent.</p>
    
    <p>SOLUTION UPDATE:</p>
    
    <p>The problem with phantomjs is disabling images. When I use
    <code>--load-images=no</code> I face with the memory leak issue and scripts gets really slower, without it there
    is no problem.</p>
  </blockquote>