Capture Your Web page with Python Power.

Website screenshot API use case.


Very often webmasters require to obtain webpages screenshots for certain domain and there is a very useful online service for web developers and SEO professionals on "WhoisXML API" that provides Domain & IP Data Intelligence for Greater Enterprise Security and RESTful APIs that we will use.

Using it's APIs you can perform many handy data requests, for example you can get a webpeges screenshots for a certain website - don't forget to get your API KEY. In the following example the simple use of screenshot API is shown, using additional parameters you can change the output image type, size, quality, etc...

Webpage screenshot.
Webpage screenshot meme.

Python Knowledge Base: Make coding great again.
- Updated: 2024-12-01 by Andrey BRATUS, Senior Data Analyst.



    This Python script below will use information from "WhoisXML API" and provide you a result image without the need to use a web browser.
    Making websites screenshots can be easily automated now !



  1. Python code to make a Webpage screenshot:


  2. 
    # screenshot of any web page with one API
    import requests
    from PIL import Image
    
    
    website = 'python-code.pro'
    
    APIKEY ='at_ZUVkrukr4Uhhhsfq2j6dyv2VhFGWYV'
       
    screenshot_request_url = f'https://website-screenshot.whoisxmlapi.com/api/v1?apiKey={APIKEY}&url={website}&credits=DRS'
    
    r = requests.get(screenshot_request_url)
    
    with open("screenshot_image.jpg", "wb") as f:
        f.write(r.content)
    
    print(f'Screenshot for {website} domain. \n')
    img = Image.open(r'screenshot_image.jpg')
    img
    

  3. Making Webpage screenshot output:


  4. page screenshot output.





See also related topics: