Added archive support, and the IP archive.

This commit is contained in:
2018-05-05 00:51:58 +02:00
parent 1b3a334c24
commit ca3bdd717d
14 changed files with 117 additions and 31 deletions

7
src/archives/archives.js Normal file
View File

@@ -0,0 +1,7 @@
'use strict';
const ip = require('./ip.js');
module.exports = {
ip
};

21
src/archives/ip.js Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
const fetch = require('node-fetch');
const $ = require('cheerio');
function findOnIp(username, page = 1, acc = []) {
return Promise.resolve().then(() => {
return fetch(`https://www.imageporn.net/user/${username}/all/${page}`);
}).then(res => res.text()).then(res => {
const postIds = $('.icon a', res).toArray().map(link => link.attribs.href.slice(16));
if(postIds.length) {
// still finding items, check next page
return findOnIp(username, ++page, acc.concat(postIds))
}
return acc;
});
};
module.exports = findOnIp;