HOME/Articles/

pil example screenshot psu (snippet)

Article Outline

Python pil example 'screenshot psu'

Modules used in program:

  • import requests
  • import sys
  • import io

python screenshot psu

Python pil example: screenshot psu

import io
import sys
import requests
from PIL import Image

if len(sys.argv) != 2:
    print("Usage: screenshot_psu.py <filename>")
    sys.exit(1)

# first log in
requests.get("http://psu.bench/cgi/login?pass=keysight")
# now download screenshot
r = requests.get("http://psu.bench/get/screenshot.bmp")
# convert to PNG and save
img = Image.open(io.BytesIO(r.content))
img.save(sys.argv[1])