Help us understand the problem. What is going on with this article?

pixivの技術ブログで紹介されてたHeadless Chromeのコードをchromyで3分の1にしてみた

More than 1 year has passed since last update.

下記の記事で紹介されていたコードをchromyで書き直してみた。

Headless Chromeでデザイン変更履歴を追える魚拓を作ってみた

元コードが空行とコメント抜いて66行くらいで、chromyで書いたコードが21行。

const Chromy = require('chromy')
const util = require('util')
const fs = require('fs')

const writeFile = util.promisify(fs.writeFile)

async function main () {
  const chromy = new Chromy({waitFunctionPollingInterval: 200})
  await chromy.chain()
    .goto('https://www.pixiv.net/')
    .wait(_ => {
      const result = (window.scrollY + window.innerHeight >= window.document.body.scrollHeight)
      window.scrollTo(0, window.scrollY + window.innerHeight)
      return result
    })
    .screenshotDocument()
    .result((image) => {
      return writeFile('capture.png', image)
    })
    .end()
    .then(_ => chromy.close())
}

main()
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした