Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const devices = require('puppeteer/DeviceDescriptors');
let fetch = require('node-fetch');
let FormData = require('form-data');
let fs = require('fs');
let opener = require('opener');
it('スマートフォン版のスクリーンショットを撮影', async function () {
this.timeout(20000);
await page.emulate(devices['iPhone 6']);
await page.screenshot({
path: 'iphone6.png',
fullPage: true
});
// yabumiにアップロード
const formData = new FormData();
formData.append('imagedata', fs.createReadStream('iphone6.png'));
await fetch('https://yabumi.cc/api/images.json', {
method: 'POST',
body: formData
})
.then(function (res) {
return res.json();
}).then(async function (json) {
console.log(json);
if (json.url) {
await opener(json.url);
}
fs.unlinkSync('iphone6.png');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.