dumbest mistake ever
This commit is contained in:
parent
c8cba84c19
commit
d2bb8524bc
2 changed files with 25 additions and 25 deletions
2
rank.js
2
rank.js
|
@ -89,7 +89,7 @@ function rankCalc(result, iterations = 10, main = [], domain_mode = false) {
|
||||||
for (let i = 0; i < mm; i++) {
|
for (let i = 0; i < mm; i++) {
|
||||||
let prold = pr;
|
let prold = pr;
|
||||||
|
|
||||||
pr = [];
|
pr = {};
|
||||||
|
|
||||||
let msum = 0;
|
let msum = 0;
|
||||||
console.log(`Completed ${i} iterations`)
|
console.log(`Completed ${i} iterations`)
|
||||||
|
|
48
site.js
48
site.js
|
@ -15,7 +15,9 @@ let percent = 0;
|
||||||
let d = process.env.depth || 1;
|
let d = process.env.depth || 1;
|
||||||
|
|
||||||
async function urlCollector(url, path, file, useLimit, data2) {
|
async function urlCollector(url, path, file, useLimit, data2) {
|
||||||
if (path != 'following') return [];
|
let urls = data2[url] ? (data2[url][path] || []) : [];
|
||||||
|
urls = [...urls];
|
||||||
|
if (path != 'following') return urls;
|
||||||
|
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
|
@ -24,17 +26,18 @@ async function urlCollector(url, path, file, useLimit, data2) {
|
||||||
console.log(`User ${url} was fetched`);
|
console.log(`User ${url} was fetched`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(`User ${url} did not fetch`);
|
console.warn(`User ${url} did not fetch`);
|
||||||
return [];
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = cheerio.load(data);
|
let body = cheerio.load(data);
|
||||||
let links = body('a');
|
let links = body('a');
|
||||||
let urls = data2[url] ? (data2[url][path] || []) : [];
|
|
||||||
let ll = urls.length;
|
let ll = urls.length;
|
||||||
links.each(function (i, link) {
|
links.each(function (i, link) {
|
||||||
if (useLimit && urls.length >= pageLimit * 40 + ll) return;
|
if (useLimit && urls.length >= pageLimit * 40 + ll) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
let h = body(link).attr('href');
|
let h = body(link).attr('href');
|
||||||
if (!h) return;
|
if (!h) return true;
|
||||||
h = h.trim();
|
h = h.trim();
|
||||||
if (h.startsWith('./') || h.startsWith('../') || h.startsWith('/')) {
|
if (h.startsWith('./') || h.startsWith('../') || h.startsWith('/')) {
|
||||||
let u = new URL(url);
|
let u = new URL(url);
|
||||||
|
@ -45,15 +48,17 @@ async function urlCollector(url, path, file, useLimit, data2) {
|
||||||
try {
|
try {
|
||||||
h2 = new URL(h);
|
h2 = new URL(h);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (!h2) return true;
|
||||||
for (let g of greylist) {
|
for (let g of greylist) {
|
||||||
if (h2.toString().includes(g) && g != '') return;
|
if (h2.toString().includes(g) && g != '') return true;
|
||||||
}
|
}
|
||||||
if (blacklist.indexOf(h2.toString()) != -1) return;
|
if (blacklist.indexOf(h2.toString()) != -1) return true;
|
||||||
urls.push(h2.toString());
|
urls.push(h2.toString());
|
||||||
urls = [...new Set(urls)];
|
urls = [...new Set(urls)];
|
||||||
console.log(`User ${url} has ${urls.length} pages calculated`);
|
console.log(`User ${url} has ${urls.length} pages calculated`);
|
||||||
|
return true;
|
||||||
})
|
})
|
||||||
|
|
||||||
let h3;
|
let h3;
|
||||||
|
@ -64,9 +69,9 @@ async function urlCollector(url, path, file, useLimit, data2) {
|
||||||
}
|
}
|
||||||
urls.push(h3.toString())
|
urls.push(h3.toString())
|
||||||
if (!data2[url]) data2[url] = { following: [], followers: [] };
|
if (!data2[url]) data2[url] = { following: [], followers: [] };
|
||||||
data2[url][path] = urls;
|
data2[url][path] = [...new Set(urls)];
|
||||||
|
|
||||||
return [...new Set(urls)];
|
return data2[url][path];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rounder(users, data, mode) {
|
async function rounder(users, data, mode) {
|
||||||
|
@ -99,7 +104,7 @@ async function rounder(users, data, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timeout) break;
|
if (timeout) break;
|
||||||
data[u] = { followers: [], following: [] };
|
if (!data[u]) data[u] = { followers: [], following: [] };
|
||||||
p.push(async function (k) {
|
p.push(async function (k) {
|
||||||
await siteCollector(u, 'followers', site, mode, data);
|
await siteCollector(u, 'followers', site, mode, data);
|
||||||
|
|
||||||
|
@ -129,16 +134,8 @@ async function rounder(users, data, mode) {
|
||||||
let endn = [...users];
|
let endn = [...users];
|
||||||
let oldLength = endn.length;
|
let oldLength = endn.length;
|
||||||
for (let h in data) {
|
for (let h in data) {
|
||||||
let dh = data[h];
|
endn.push(h);
|
||||||
if (dh.following.length == 0 && dh.followers.length == 0) continue;
|
if (endn.length > oldLength * 1.25 || endn.length - oldLength > userLimit) {
|
||||||
let ffing = [...dh.following];
|
|
||||||
let ffers = [...dh.followers];
|
|
||||||
if (mode) {
|
|
||||||
ffing.length = Math.min(ffing.length, userLimit);
|
|
||||||
ffers.length = Math.min(ffers.length, userLimit);
|
|
||||||
}
|
|
||||||
endn = endn.concat(ffing, ffers);
|
|
||||||
if (endn.length > oldLength * 1.25) {
|
|
||||||
endn = [...new Set(endn)];
|
endn = [...new Set(endn)];
|
||||||
}
|
}
|
||||||
if (mode && endn.length - oldLength > userLimit) break;
|
if (mode && endn.length - oldLength > userLimit) break;
|
||||||
|
@ -166,7 +163,8 @@ async function textCollector(word, path, file) {
|
||||||
async function siteCollector(user, path, site, useLimit, data2) {
|
async function siteCollector(user, path, site, useLimit, data2) {
|
||||||
let users = [];
|
let users = [];
|
||||||
let urls = data2[user] ? (data2[user][path] || []) : [];
|
let urls = data2[user] ? (data2[user][path] || []) : [];
|
||||||
let i = 1 + (urls.length || 0);
|
let ul = urls.length;
|
||||||
|
let i = 1 + (ul || 0);
|
||||||
let out = [];
|
let out = [];
|
||||||
|
|
||||||
if (site == 'file') {
|
if (site == 'file') {
|
||||||
|
@ -199,7 +197,7 @@ async function siteCollector(user, path, site, useLimit, data2) {
|
||||||
}
|
}
|
||||||
cache[p] = j1;
|
cache[p] = j1;
|
||||||
|
|
||||||
if (!j1 || ((i - urls.length - 1) >= pageLimit && useLimit)) break;
|
if (!j1 || ((i - ul - 1) >= pageLimit && useLimit)) break;
|
||||||
|
|
||||||
let users2;
|
let users2;
|
||||||
try {
|
try {
|
||||||
|
@ -250,7 +248,9 @@ async function siteCollector(user, path, site, useLimit, data2) {
|
||||||
}
|
}
|
||||||
for (let uf of users) {
|
for (let uf of users) {
|
||||||
let u = data[uf];
|
let u = data[uf];
|
||||||
if (!u) continue;
|
if (!u) {
|
||||||
|
data[uf] = {following: [], followers: []}
|
||||||
|
}
|
||||||
let { following, followers } = u;
|
let { following, followers } = u;
|
||||||
if (!following || !followers) continue;
|
if (!following || !followers) continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue