Added archive support, and the IP archive.
This commit is contained in:
7
src/archives/archives.js
Normal file
7
src/archives/archives.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const ip = require('./ip.js');
|
||||
|
||||
module.exports = {
|
||||
ip
|
||||
};
|
||||
21
src/archives/ip.js
Normal file
21
src/archives/ip.js
Normal 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;
|
||||
Reference in New Issue
Block a user