22 lines
614 B
JavaScript
22 lines
614 B
JavaScript
'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;
|