mirror of
https://gitlab.com/moepoi/NekopoiScrapper.git
synced 2024-11-21 22:06:23 +01:00
Update url & Optimize getLatest
This commit is contained in:
parent
b7770e4483
commit
ef2686df6a
1 changed files with 33 additions and 33 deletions
|
@ -7,16 +7,16 @@
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
let url = 'http://nekopoi.cash';
|
|
||||||
let title = [];
|
|
||||||
let link = [];
|
|
||||||
let image = [];
|
|
||||||
let data = [];
|
|
||||||
|
|
||||||
const getLatest = () => {
|
const getLatest = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(url).then(function(req) {
|
const url = 'http://nekopoi.care';
|
||||||
let soup = cheerio.load(req.data);
|
axios.get(url)
|
||||||
|
.then(req => {
|
||||||
|
const title = [];
|
||||||
|
const link = [];
|
||||||
|
const image = [];
|
||||||
|
const data = [];
|
||||||
|
const soup = cheerio.load(req.data);
|
||||||
soup('div.eropost').each(function(i, e) {
|
soup('div.eropost').each(function(i, e) {
|
||||||
soup(e).find('h2').each(function(j, s) {
|
soup(e).find('h2').each(function(j, s) {
|
||||||
title.push(soup(s).find('a').text().trim());
|
title.push(soup(s).find('a').text().trim());
|
||||||
|
@ -33,7 +33,7 @@ const getLatest = () => {
|
||||||
};
|
};
|
||||||
data.push(isi);
|
data.push(isi);
|
||||||
}
|
}
|
||||||
if (data == null) {
|
if (data == undefined) {
|
||||||
reject("No result :(");
|
reject("No result :(");
|
||||||
} else {
|
} else {
|
||||||
var result = JSON.stringify(data, null, 2);
|
var result = JSON.stringify(data, null, 2);
|
||||||
|
|
Loading…
Reference in a new issue