I earn my living writing content in one form or another. I write for myself, as a ghost writer or as a copywriter for blogs, websites, magazines, businesses or newspapers. One thing that’s always bothered me was the repetitive task of grabbing screenshots from websites. And especially when I am doing roundups or other lists of some kind, it is time consuming and not very funny to take 50+ screenshots of different websites for machine learning frameworks, just to give an example.
So I set out to write a few lines of Python code to help me with this very specific task. That article I linked to earlier is a great example of what this script does. Except the new version doesn’t show scrollbar on the right side since that was annoying.
The result is an unordered list ready for descriptions to make a quick and easy post of any kind using screenshots from websites. Posting to WordPress automatically using xmlrpc.php is an easy way but might not work for all hosts.
I’ve also posted it all on GitHub, so head over there if you prefer.
This has so far only been tested on Windows 7 with Python 3.5 – some modifications might need to take place in order for this to work on other systems.
Screengrabber also uses a few different dependencies:
pip install selenium pip install python-wordpress-xmlrpc pip install pillow
- Simply clone screengrabber.py and save it in a folder of your choosing.
- Then create a subfolder in the directory called “img”
- Download chromedriver.exe and place in root folder where screengrabber.py also exists
- Configure details in screengrabber.py
To configure screengrabber.py line 8 and line 18 needs to modified.
- First you need to setup your WordPress URL, USERNAME and PASSWORD on line 8:
wp = Client('http://localhost/wordpress/xmlrpc.php', 'USERNAME', 'PASSWORD')
- Then go to line 18 and change:
# CHANGE THIS VARIABLE TO YOUR CORRECT SYSTEM FOLDER BUT DONT CHANGE THE LAST BIT imagelocation = "C:/CHANGE/THIS/PATH/img/%s.jpg" %idx
Important: Do not change the last bit containing
- All done! Run the script by using your command line or create a .BAT file