feat: metaculus fetcher takes markdown description from js vars
This commit is contained in:
parent
4d736f711d
commit
d684d074f5
|
@ -4,7 +4,6 @@ import axios from "axios";
|
||||||
|
|
||||||
import { average } from "../../utils";
|
import { average } from "../../utils";
|
||||||
import { sleep } from "../utils/sleep";
|
import { sleep } from "../utils/sleep";
|
||||||
import toMarkdown from "../utils/toMarkdown";
|
|
||||||
import { FetchedQuestion, Platform } from "./";
|
import { FetchedQuestion, Platform } from "./";
|
||||||
|
|
||||||
/* Definitions */
|
/* Definitions */
|
||||||
|
@ -134,11 +133,13 @@ async function fetchQuestionPage(slug: string) {
|
||||||
|
|
||||||
let description: string = "";
|
let description: string = "";
|
||||||
if (!isPublicFigurePrediction) {
|
if (!isPublicFigurePrediction) {
|
||||||
const descriptionraw = questionPage.split(
|
const match = questionPage.match(
|
||||||
`<div class="content" ng-bind-html-compile="qctrl.question.description_html">`
|
/\s*window\.metacData\.question = (.+);\s*/
|
||||||
)[1];
|
);
|
||||||
const descriptionprocessed1 = descriptionraw.split("</div>")[0];
|
if (!match) {
|
||||||
description = toMarkdown(descriptionprocessed1);
|
throw new Error("metacData not found");
|
||||||
|
}
|
||||||
|
description = JSON.parse(match[1]).description;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user