This repository has been archived by the owner on May 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanga-fetcher.js
57 lines (54 loc) · 2.09 KB
/
manga-fetcher.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
if (Meteor.isClient) {
Template.hello.greeting = function () {
return "Welcome to manga-fetcher.";
};
Template.hello.events({
'click input': function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
var CheerioLib = Meteor.require('cheerio');
var FsLib = Meteor.require('fs');
var HttpLib = Meteor.require('http');
try{
// var mangaSpaceOp = HTTP.get('http://mangaspaceserver.org/data/manga/op/754/');
var mangaSpaceOp = HTTP.get('http://www.webcopedia.fr/index.php/lel/read/26/11/7541/1');
var $cheerioPage = CheerioLib.load(mangaSpaceOp.content);
// console.dir(mangaSpaceOp);
// console.dir($cheerioPage('#page_box').html());
// console.dir($cheerioPage('#page_box').html());
// console.log($cheerioPage('#page_box').find('img'));
// console.log($cheerioPage('#page_box').find('img').text());
// console.log($cheerioPage('#page_box').find('img').attr('src'));
// console.log($cheerioPage('#page_box').html());
// console.log($cheerioPage('p.centre').find('a').html());
// console.log($cheerioPage('img'));
console.log($cheerioPage('img').attr('src'));
var file = FsLib.createWriteStream('./test4.jpg');
HttpLib.get($cheerioPage('img').attr('src'), function(res){
res.on('data', function(data) {
file.write(data);
}).on('end', function() {
file.end();
});
});
// request($cheerioPage('img').attr('src')).pipe( FsLib.createWriteStream('./test4.jpg'));
// console.log(img);
// if(img.content != ''){
// // var test = FsLib.writeFileSync('test.jpg', img.content);
// // console.log(FsLib.realpathSync('.'));
// // console.log(img.content);
// var test = FsLib.writeFileSync('./test4.jpg', img.content, 'ascii');
// }
// console.log(img);
}
catch(e){
console.log('-- Cant fetch from mangaSpace Url --');
}
});
}