-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcastdown.js
93 lines (54 loc) · 2.29 KB
/
castdown.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var request = require('request');
var fs = require('fs')
const download = require('image-downloader')
const { encode, decode } = require('url-encode-decode')
var sleep = require('system-sleep');
const cheerio = require("cheerio");
var os = require('os');
function castindir(isimler){
setTimeout(function () {
var postlist = isimler.split(',');
var liste = []
liste = postlist
var downcastlong = liste.length
console.log(downcastlong)
liste.forEach((element, index) => {
var yenielement = encode(element)
request.get('https://www.imdb.com/find?q=' + yenielement + '&ref_=nv_sr_sm', { timeout: 15000 }, function (error, response, html) {
if (error) {
console.log(error)
}
const $ = cheerio.load(html);
$("td[class='primary_photo'] > a > img").each((index2, inelement) => {
if (index2 == 0) {
var bulunanresimyolu = $(inelement).attr("src")
if (bulunanresimyolu.includes('https://m.media-amazon.com/images/S/sash')) {
var normalisim = decode(yenielement)
} else {
var normalisim = decode(yenielement)
var alttireliisim = normalisim.split(' ').join('_');
var buyukresimyolu = bulunanresimyolu.split('_V1')
var sonresimyolu = buyukresimyolu[0] + '_V1'
if(alttireliisim.includes('\r\n')){
alttireliisim = alttireliisim.split('\r\n').join('');
}
const options = {
url: sonresimyolu,
dest: '.\\images\\' + alttireliisim + '.jpg'
}
download.image(options)
.then(({ filename }) => {
console.log('Download is successful: ' + filename)
})
.catch((err) => console.error(err))
}
}
});
});
sleep(2000);
})
}, 0);
}
module.exports ={
castindir,
}