Sending Scrape Requests

https://api.usetrove.io/v1/scrape/browser?key=<YOUR_TROVE_KEY>

Sending scrape requests is simple and responses will be sent as application/json. You can see samples below for Node.js, Python and PHP. All requests are made with the POST method.


Send a request using https

For Node.js there are plenty of third party libraries as well, such as node-fetch or got.

const https = require('https');
const TROVE_KEY = '<YOUR_TROVE_KEY>';
const TROVE_API = `https://api.usetrove.io/v1/scrape/browser?key=${TROVE_KEY}`;
function handleResponse(response) {
response.setEncoding('utf8');
response.on('data', function (data) {
const jsonResponse = JSON.parse(data);
console.log(jsonResponse);
});
}
function sendRequest(postBody) {
const url = new URL(TROVE_API);
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
};
const request = https.request(url, requestOptions, handleResponse);
request.write(JSON.stringify(postBody));
request.end();
}
sendRequest({
url: 'https://google.com/search?q=social%20media%20marketing',
output: {
ads: [
{
required: true,
label: 'ad_link',
attribute: 'data-pcu',
selector: "//div/div/div/div/a[contains(., 'ad')][@data-pcu]",
},
{
label: 'ad_company',
selector:
"//div/div/div/div/a[contains(., 'ad')][@data-pcu]/div[@role='heading']/span",
},
{
label: 'ad_text',
selector:
"//div/div/div/div/a[contains(., 'ad')][@data-pcu]/../following-sibling::div[1]",
},
],
},
});
// {
// ads: [
// {
// ad_link: 'https://www.chetu.com/',
// ad_company: 'Social Media Marketing System - Development. Custom Solutions',
// ad_text: 'Get Custom Software for Marketing Technologies, Automation, & Lead Management. Learn More on our Site and Contact a Representative. Live Reps Available Now. 3000+ Worldwide Clients. 16000+ Apps Developed. Services: Customization, Development, Updates.'
// }
// ...more ads