-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.js
32 lines (23 loc) · 864 Bytes
/
3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const Crawler = require('crawler');
const cherio = require('cherio');
const fs = require('fs');
const download = require('images-downloader').images;
const dest = 'x';
var array = [];
fs.readFile('objects.json', 'utf8', (err, data) => {
if (err) {
console.log(`Error reading file from disk: ${err}`);
} else {
// parse JSON string to JSON object
array = JSON.parse(data);
const links = array.map(function(l) {
return "https://dkstatics-public.digikala.com/digikala-products/" + l.substring(0, l.indexOf('?')) + "?x-oss-process=image/resize,h_500/quality,q_10";
});
console.log(links);
download(links, dest)
.then(result => {
console.log(result);
})
.catch(error => console.log("downloaded error", error))
}
});