Answer the question
In order to leave comments, you need to log in
How to take screenshot with python script?
There is a python code:
import pyscreenshot as ImageGrab
from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
display = Display(visible=0, size=(1366, 768)).start()
browser = webdriver.Firefox()
browser.get('https://google.com')
browser.implicitly_wait(10)
print browser.title
img = ImageGrab.grab()
img.save('screen.png');
browser.quit()
display.stop()
Traceback (most recent call last):
File "script.py", line 13, in <module>
img = ImageGrab.grab()
File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/__init__.py", line 70, in grab
return _grab(to_file=False, childprocess=childprocess, backend=backend, bbox=bbox)
File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/__init__.py", line 50, in _grab
backend_obj = _get_loader().selected()
File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/loader.py", line 75, in selected
self.raise_exc()
File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/loader.py", line 83, in raise_exc
raise FailedBackendError(message)
pyscreenshot.loader.FailedBackendError: Install at least one backend!
Answer the question
In order to leave comments, you need to log in
The answer was simple. I read in the documentation on GitHub that:
And just below:
Plugin based, it has wrappers for various back-ends:
scrot
ImageMagick
PyGTK
PIL or Pillow (only on windows)
PyQt4
wxPython
Quartz (Mac)
screencapture (Mac)
You can turn to third-party tools, for example. The same imagemagick allows you to take screenshots. Call, for example, via subprocess.call.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question