Skip to content

Commit

Permalink
Add referral parsing to fimfic stats
Browse files Browse the repository at this point in the history
  • Loading branch information
SilkRose committed Mar 6, 2024
1 parent 3938a23 commit 67fd9a5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fimficstats/fimfic-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ async function mane() {
const bookshelves = Number(document(books[0]).text().replace(/\D/g, ""));
const tracking = Number(document(books[1]).text().replace(/\D/g, ""));

// Get the number of referrals from each site from the HTML.
let referrals: Record<string, number> = {};

document('h1:contains("Referrals")')
.next("ul")
.find("li")
.each(function () {
const [site, count] = document(this).text().split(": ");
referrals[site] = Number(count);
});

if (Object.keys(referrals).length > 0) {
console.log(referrals);
}

// Log variables to console for testing.
console.log(rating, word_ranking, bookshelves, tracking);
console.log(id, api_json);
Expand Down

0 comments on commit 67fd9a5

Please sign in to comment.