tweak: Clean infer description + cosmetic changes
This commit is contained in:
parent
789fafd0f6
commit
5e7596e6e7
|
@ -20,6 +20,12 @@ const SLEEP_TIME_EXTRA = 2000;
|
||||||
|
|
||||||
/* Support functions */
|
/* Support functions */
|
||||||
|
|
||||||
|
function cleanDescription(text) {
|
||||||
|
let md = toMarkdown(text);
|
||||||
|
let result = md.replaceAll("---", "-").replaceAll(" ", " ");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchPage(page, cookie) {
|
async function fetchPage(page, cookie) {
|
||||||
console.log(`Page #${page}`);
|
console.log(`Page #${page}`);
|
||||||
if (page == 1) {
|
if (page == 1) {
|
||||||
|
@ -68,7 +74,7 @@ async function fetchStats(questionUrl, cookie) {
|
||||||
});
|
});
|
||||||
let firstEmbeddedJson = embeddedJsons[0];
|
let firstEmbeddedJson = embeddedJsons[0];
|
||||||
let title = firstEmbeddedJson.question.name;
|
let title = firstEmbeddedJson.question.name;
|
||||||
let description = firstEmbeddedJson.question.description;
|
let description = cleanDescription(firstEmbeddedJson.question.description);
|
||||||
let comments_count = firstEmbeddedJson.question.comments_count;
|
let comments_count = firstEmbeddedJson.question.comments_count;
|
||||||
let numforecasters = firstEmbeddedJson.question.predictors_count;
|
let numforecasters = firstEmbeddedJson.question.predictors_count;
|
||||||
let numforecasts = firstEmbeddedJson.question.prediction_sets_count;
|
let numforecasts = firstEmbeddedJson.question.prediction_sets_count;
|
||||||
|
@ -120,17 +126,17 @@ function isSignedIn(html) {
|
||||||
if (!isSignedInBool) {
|
if (!isSignedInBool) {
|
||||||
console.log("Error: Not signed in.");
|
console.log("Error: Not signed in.");
|
||||||
}
|
}
|
||||||
console.log(`Signed in? ${isSignedInBool}`);
|
console.log(`Signed in? ${isSignedInBool ? "yes" : "no"}`);
|
||||||
return isSignedInBool;
|
return isSignedInBool;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEnd(html) {
|
function reachedEnd(html) {
|
||||||
let isEndBool = html.includes("No questions match your filter");
|
let reachedEndBool = html.includes("No questions match your filter");
|
||||||
if (isEndBool) {
|
if (reachedEndBool) {
|
||||||
//console.log(html)
|
//console.log(html)
|
||||||
}
|
}
|
||||||
console.log(`IsEnd? ${isEndBool}`);
|
console.log(`Reached end? ${reachedEndBool ? "yes" : "no"}`);
|
||||||
return isEndBool;
|
return reachedEndBool;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
|
@ -146,7 +152,7 @@ async function infer_inner(cookie: string) {
|
||||||
|
|
||||||
await measureTime(async () => {
|
await measureTime(async () => {
|
||||||
// console.log("Downloading... This might take a couple of minutes. Results will be shown.")
|
// console.log("Downloading... This might take a couple of minutes. Results will be shown.")
|
||||||
while (!isEnd(response) && isSignedIn(response)) {
|
while (!reachedEnd(response) && isSignedIn(response)) {
|
||||||
let htmlLines = response.split("\n");
|
let htmlLines = response.split("\n");
|
||||||
// let h4elements = htmlLines.filter(str => str.includes("<h5> <a href=") || str.includes("<h4> <a href="))
|
// let h4elements = htmlLines.filter(str => str.includes("<h5> <a href=") || str.includes("<h4> <a href="))
|
||||||
let questionHrefs = htmlLines.filter((str) =>
|
let questionHrefs = htmlLines.filter((str) =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user