Last active
October 30, 2019 18:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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