Output Types
Plain HTML
By default, the scraper API returns plain HTML without requiring any additional parameters. This does not require javascript rendering to be enabled! Here are some examples:
Request
- Axios
- Curl
const axios = require('axios').default;
const options = {
method: 'GET',
url: 'https://api.scrapeautomate.com/scraper',
params: {
apiKey: '<exampleToken>',
render: 'false',
url: 'https://example.com/',
},
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
curl --request GET \
--url 'https://api.scrapeautomate.com/scraper?apiKey=<exampleToken>&render=false&url=https%3A%2F%2Fexample.com%2F'
Screenshot
Full Page Screenshot
To capture a full-page screenshot, set the screenshot_full_page
parameter to true. This captures the entire length of the web page. This requires for render to be enabled!
- Axios
- Curl
const axios = require('axios').default;
const options = {
method: 'GET',
url: 'https://api.scrapeautomate.com/scraper',
params: {
apiKey: '<exampleToken>',
render: 'true',
url: 'https://example.com/',
screenshot_full_page: 'true',
},
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
curl --request GET \
--url 'https://api.scrapeautomate.com/scraper?apiKey=<exampleToken>&render=true&url=https%3A%2F%2Fexample.com%2F&screenshot_full_page=true'
Viewport Screenshot
To capture a screenshot of the current viewport or how much the current user can see, set the screenshot
parameter to true. This captures only the visible part of the web page within the viewport. This requires for render to be enabled!
- Axios
- Curl
const axios = require('axios').default;
const options = {
method: 'GET',
url: 'https://api.scrapeautomate.com/scraper',
params: {
apiKey: '<exampleToken>',
render: 'true',
url: 'https://example.com/',
screenshot: 'true',
},
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
curl --request GET \
--url 'https://api.scrapeautomate.com/scraper?apiKey=<exampleToken>&render=true&url=https%3A%2F%2Fexample.com%2F&screenshot=true'
Webhook
If you would like for your responses to be sent to a webhook rather then directly responding with the response then you can use the webhook webhook_url
property. You can use this on addition to screenshots or html. To use this just pass your webhook_url in the query parameters and the response from the api will be sent to that webhook. Here is an demo:
- Axios
- Curl
const axios = require('axios').default;
const options = {
method: 'GET',
url: 'https://api.scrapeautomate.com/scraper',
params: {
apiKey: '<exampleToken>',
render: 'true',
url: 'https://example.com/',
screenshot: 'true',
webhook_url: "https://webhook.site/7132edb4-8590-4bc0-9055-30e2153936d1"
},
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
curl --request GET \
--url 'http://localhost:8002/api/scraper?apiKey=<exampleToken>&render=true&url=https%253A%252F%252Fexample.com%252Fees&config=%7B%22window_width%22%3A1920%2C%22window_height%22%3A1080%7D&webhook_url=https%3A%2F%2Fwebhook.site%2F7132edb4-8590-4bc0-9055-30e2153936d1'
Now what happens is that when you hit that API it will automatically send the response to that api rather then responding with the response data to person who requested it, but you will still get a response saying weather or not if we were able to successfully hit the webhook like this:
{
"status": "ok",
"message": "Webhook sent successfully"
}
This also works with api workflows, just make sure to pass it with the query parameters when either editing or creating the webhook!