GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - screenshotmachine/screenshotmachine-python: Simple example how to call screenshot machine's API using python programming language.

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
client.py
client.py
 
 
clientPdf.py
clientPdf.py
 
 

Repository files navigation

screenshotmachine-python

This demo shows how to call online screenshot machine API using python3.

Installation

First, you need to create a free/premium account at www.screenshotmachine.com website. After registration, you will see your customer key in your user profile. Also secret phrase is maintained here. Please, use secret phrase always, when your API calls are called from publicly available websites.

Set-up your customer key and secret phrase (if needed) in the script:

customer_key = 'PUT_YOUR_CUSTOMER_KEY_HERE'
secret_phrase = '' # leave secret phrase empty, if not needed

Website screenshot API

Set additional options to fulfill your needs:

options = {
  'url': 'https://www.google.com', # mandatory parameter
  # all next parameters are optional, see our website screenshot API guide for more details
  'dimension': '1366x768', # or "1366xfull" for full length screenshot
  'device': 'desktop',
  'cacheLimit' : '0',
  'delay' : '200',
  'zoom' : '100'
  }

More info about options can be found in our Website screenshot API.

Sample code

customer_key = 'PUT_YOUR_CUSTOMER_KEY_HERE'
secret_phrase = '' # leave secret phrase empty, if not needed
options = {
  'url': 'https://www.google.com', # mandatory parameter
  # all next parameters are optional, see our website screenshot API guide for more details
  'dimension': '1366x768', # or "1366xfull" for full length screenshot
  'device': 'desktop',
  'cacheLimit' : '0',
  'delay' : '200',
  'zoom' : '100'
  }

api_url = generate_screenshot_api_url(customer_key, secret_phrase, options)

#put link to your html code
print('<img src="'  + api_url + '">')

Generated api_url link can be placed in <img> tag or used in your business logic later.

If you need to store captured screenshot as an image, just call:

api_url = generate_screenshot_api_url(customer_key, secret_phrase, options)

#save screenshot as an image
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', '-')]
urllib.request.install_opener(opener)
output = 'output.png'
urllib.request.urlretrieve(api_url, output)
print('Screenshot saved as ' + output);

Captured screenshot will be saved as output.png file in current directory.

Website to PDF API

Set the PDF options:

options = {
  'url': 'https://www.google.com', # mandatory parameter
  # all next parameters are optional, see our website to PDF API guide for more details
  'paper': 'letter',
  'orientation': 'portrait',
  'media': 'print',
  'bg' : 'nobg',
  'delay' : '2000',
  'scale' : '50'
}

More info about options can be found in our Website to PDF API.

Sample code

customer_key = 'PUT_YOUR_CUSTOMER_KEY_HERE'
secret_phrase = '' # leave secret phrase empty, if not needed
options = {
  'url': 'https://www.google.com', # mandatory parameter
  # all next parameters are optional, see our website to PDF API guide for more details
  'paper': 'letter',
  'orientation': 'portrait',
  'media': 'print',
  'bg' : 'nobg',
  'delay' : '2000',
  'scale' : '50'
}

pdf_api_url = generate_pdf_api_url(customer_key, secret_phrase, options)

#save PDF file
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', '-')]
urllib.request.install_opener(opener)
output = 'output.pdf'
urllib.request.urlretrieve(pdf_api_url, output)
print('PDF saved as ' + output);

Captured PDF will be saved as output.pdf file in the current directory.

License

The MIT License (MIT)

About

Simple example how to call screenshot machine's API using python programming language.

www.screenshotmachine.com

Topics

apicapture-screenshotsfullpage-screenshothtml-to-pdf-converterhtml2pdfpdf-converterpythonpython3screenshotscreenshot-generatorscreenshot-libraryscreenshot-utilityscreenshotsthumbnail-generatorwebpage-scraperwebsite-screenshotwebsite-thumbnailwebsite-to-pdf

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.