Created
September 2, 2017 06:36
-
-
Save FujiHaruka/a742dda710b27f9061965177a4859fab to your computer and use it in GitHub Desktop.
Headless chrome example to search instagram
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 Chromy = require('chromy') | |
const hashtag = 'しまむら' | |
const chromy = new Chromy() | |
chromy.chain() | |
.goto(`https://www.instagram.com/explore/tags/${hashtag}/`) | |
.wait('img') // wait to render | |
.evaluate(() => { | |
const images = document.querySelectorAll('img') | |
return Array.from(images).map( | |
(img) => img.src | |
) | |
}) | |
.result((urls) => console.log(urls)) | |
.end() | |
.catch((e) => { | |
console.log() | |
}) | |
.then(() => chromy.close()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment