A tutorial on our API that converts web pages to image in bulk

In this post I will discuss how you can convert web pages to images using CronDock html2img mini app

In the previous article I discussed how you can develope Two-Factor-Authentication (2FA) in python Flask using CronDock sms2fa mini app. In this article, I want to talk about an API you can use to convert web pages to images in bulk.

Using CronDock html2img RESTful API you can easily convert web pages to image in bulk. After signing up, CronDock web portal will provide you with an API key which can be used to call the CronDock RESTful API. Using the API key you can call CronDock via different tools such as "curl", python libraries (such as "requests") or tools such as postman .

CronDock API end point is https://api.crondock.com/. Keep in mind that in all your API calls to CronDock API endpoint, you should add your "API key" in a Header called "Authorization" and you need to add "Api-Key " at its begining. So for instance in "curl" you will have something like (replace XXXXX with your "API key"):

curl -X GET -H "Content-Type: application/json" -H "Authorization: Api-Key XXXXX" https://api.crondock.com/run/html2img/html2img-123456/
                

I am implementing different mini apps in CronDock that are accessible via the same api. The mini app for converting websites to image is called html2img and can be accessed via https://api.crondock.com/run/html2img/ endpoint. Using this mini app you basically can pass multiple urls and the api will provide you with links to download the image version of those websites. To do that, you need to make a POST request to https://api.crondock.com/run/html2img/ endpoint and provide the urls as a list to the request payload:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Api-Key XXXXX" -d '{
   "urls": ["https://google.com", "https://yahoo.com"]
}' https://api.crondock.com/run/html2img/
               

The response from the API will be something like below:

{"status": "OK", "job": "html2img-t20pg7"}
              

The job name provided in the response can be used to pull the end results:

curl -X GET -k --url https://api.crondock.com/run/html2img/html2img-t20pg7/ -H "Content-Type: application/json" -H "Authorization: Api-Key XXXXX"
               

The response will be something like:

{
  "status": "OK",
  "data": {
    "status": "Succeeded",
    "output": {
      "success": true,
      "data": [
        "https://crondock.s3.amazonaws.com/htmltoimage/b6c7cec0-8b39-49e6-908a-e1b2d8f84956.png?AWSAccessKeyId=AKIAWCRKQQPUVELP5AGD&Signature=U%2FOA5AKHRml8H1ee3S3LnDtiqqU%3D&Expires=1663636628",
        "https://crondock.s3.amazonaws.com/htmltoimage/2fb4a61c-5cc3-4c52-8bb4-a376b15e1d26.png?AWSAccessKeyId=AKIAWCRKQQPUVELP5AGD&Signature=ym66YnJ67nMO7DXYxqDo5t7D3gM%3D&Expires=1663636629"
        ]
      }
    }
  }
               

In which you can find the download links to the images.

Beside convering websites to images, there are other things you can do with CronDock:

Using CronDock for two-factor authentication

Or programmatically create cron jobs that run on a frequent basis

Or jobs that run at a specific time.

Or even jobs with dependencies.

Please let me know if you have any question at support@crondock.com

I also have a good document which provides more detailed information on all the requests you can make to CronDock API.