Skip to content

Instantly share code, notes, and snippets.

Created December 9, 2017 11:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save conanak99/e9312799ff04094466309031639c38e4 to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
const download = require('image-downloader');
(async() => {
const browser = await puppeteer.launch();
console.log('Browser openned');
const page = await browser.newPage();
const url = '';
await page.goto(url);
console.log('Page loaded');
const imgLinks = await page.evaluate(() => {
let imgElements = document.querySelectorAll('.sp-img-zoom > img, .sp-img-lightbox > img, .detail-img-lightbox > img');
imgElements = [...imgElements];
let imgLinks = => i.getAttribute('src'));
return imgLinks;
// Tải các ảnh này về thư mục hiện tại
await Promise.all( => download.image({
url: imgUrl,
dest: __dirname
await browser.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment