Skip to content

Instantly share code, notes, and snippets.

@chrisvxd
Last active October 30, 2019 18:26
Show Gist options
  • Save chrisvxd/d6e7b07241f6cd5363edbdd0d989aa35 to your computer and use it in GitHub Desktop.
Save chrisvxd/d6e7b07241f6cd5363edbdd0d989aa35 to your computer and use it in GitHub Desktop.
Puppet Master example for fetching screenshots across devices and writing to a file with device name
const request = require('request');
const fs = require('fs');
const executeRequest = (deviceName) => {
const options = {
url:
'https://api.saasify.sh/1/call/transitive-bullshit/puppet-master@a818aeac/screenshot',
qs: {
url: 'https://google.com',
emulateDevice: deviceName
},
headers: {
'content-type': 'application/json'
},
json: true,
encoding: null
};
request(options, (error, response, body) => {
if (error) throw new Error(error);
// Write to file
fs.writeFileSync(`${deviceName}.png`, body);
});
};
const devices = [
'iPhone 5',
'iPhone 6'
];
devices.forEach(device => {
executeRequest(device);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment