Skip to content

Instantly share code, notes, and snippets.

@FujiHaruka
Created September 2, 2017 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FujiHaruka/a742dda710b27f9061965177a4859fab to your computer and use it in GitHub Desktop.
Save FujiHaruka/a742dda710b27f9061965177a4859fab to your computer and use it in GitHub Desktop.
Headless chrome example to search instagram
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