mirror of
https://gitlab.com/moepoi/NekopoiScrapper.git
synced 2024-11-21 13:56:18 +01:00
Initial Release
This commit is contained in:
parent
f5dc6bdf0d
commit
a18f3fca14
5 changed files with 105 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.idea/
|
36
NekopoiScrapper/getInfo.js
Normal file
36
NekopoiScrapper/getInfo.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @author Moe Poi <moepoi@protonmail.com>
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const axios = require('axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
let links = [];
|
||||
|
||||
const getInfo = (url) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(url).then(function(req) {
|
||||
let soup = cheerio.load(req.data);
|
||||
var title = soup("title").text();
|
||||
soup('div.liner').each(function(i, e) {
|
||||
soup(e).find('div.listlink').each(function(j, s) {
|
||||
links.push(soup(s).find('a').attr('href'))
|
||||
});
|
||||
});
|
||||
var data = {
|
||||
"title": title,
|
||||
"links": links
|
||||
};
|
||||
if (data == null) {
|
||||
reject("No result :(");
|
||||
} else {
|
||||
var result = JSON.stringify(data, null, 2);
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = getInfo;
|
46
NekopoiScrapper/getLatest.js
Normal file
46
NekopoiScrapper/getLatest.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @author Moe Poi <moepoi@protonmail.com>
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const axios = require('axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
let url = 'http://nekopoi.cash';
|
||||
let title = [];
|
||||
let link = [];
|
||||
let image = [];
|
||||
let data = [];
|
||||
|
||||
const getLatest = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(url).then(function(req) {
|
||||
let soup = cheerio.load(req.data);
|
||||
soup('div.eropost').each(function(i, e) {
|
||||
soup(e).find('h2').each(function(j, s) {
|
||||
title.push(soup(s).find('a').text().trim());
|
||||
link.push(url + soup(s).find('a').attr('href'));
|
||||
});
|
||||
image.push(url + soup(e).find('img').attr('src'));
|
||||
});
|
||||
var i;
|
||||
for (i = 0; i < title.length; i++) {
|
||||
let isi = {
|
||||
"title": title[i],
|
||||
"image": image[i],
|
||||
"link": link[i]
|
||||
};
|
||||
data.push(isi);
|
||||
}
|
||||
if (data == null) {
|
||||
reject("No result :(");
|
||||
} else {
|
||||
var result = JSON.stringify(data, null, 2);
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = getLatest;
|
13
NekopoiScrapper/index.js
Normal file
13
NekopoiScrapper/index.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* @author Moe Poi <moepoi@protonmail.com>
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const getLatest = require('./getLatest');
|
||||
const getInfo = require('./getInfo');
|
||||
|
||||
module.exports = {
|
||||
getLatest,
|
||||
getInfo
|
||||
}
|
9
example.js
Normal file
9
example.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
const NekopoiScrapper = require('./NekopoiScrapper');
|
||||
|
||||
// Latest Release
|
||||
NekopoiScrapper.getLatest()
|
||||
.then((data) => console.log(data));
|
||||
|
||||
// Get Page Info
|
||||
NekopoiScrapper.getInfo("http://nekopoi.cash/dokidoki-little-ooyasan-episode-4-subtitle-indonesia")
|
||||
.then((data) => console.log(data));
|
Loading…
Reference in a new issue