How to do it

The script for this example is 04/09_screenshotapi.py.  Give this a run and it will make a screenshot.  The code is the following, and is very similar to the previous recipe in structure:

from core.website_screenshot_with_screenshotapi import WebsiteScreenshotGeneratorfrom core.file_blob_writer import FileBlobWriterfrom os.path import expanduser# get the screenshotimage_bytes = WebsiteScreenshotGenerator("bd17a1e1-db43-4686-9f9b-b72b67a5535e")\    .capture("http://espn.go.com", 500, 500).image_bytes# save it to a fileFileBlobWriter(expanduser("~")).write("website_screenshot.png", image_bytes)

The functional difference to the previous recipe is that we used a different WebsiteScreenshotGenerator implementation.  This one comes from ...

Get Python Web Scraping Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.