PlaybooksScreenshot a Webpage
Save the image
Write the image to disk.
Write the bytes of the response to a file.
This code continues the script from Check the response.
with open("screenshot.png", "wb") as file:
file.write(image)
print("Saved to screenshot.png")Leave out full_page to capture only the viewport, and set viewport_width and viewport_height to the size you need, for example 1200 × 630 for a social preview image.