feat: metaculus fetcher takes markdown description from js vars

This commit is contained in:
Vyacheslav Matyukhin 2022-05-19 13:55:56 +04:00
parent 4d736f711d
commit d684d074f5
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -4,7 +4,6 @@ import axios from "axios";
import { average } from "../../utils";
import { sleep } from "../utils/sleep";
import toMarkdown from "../utils/toMarkdown";
import { FetchedQuestion, Platform } from "./";
/* Definitions */
@ -134,11 +133,13 @@ async function fetchQuestionPage(slug: string) {
let description: string = "";
if (!isPublicFigurePrediction) {
const descriptionraw = questionPage.split(
`<div class="content" ng-bind-html-compile="qctrl.question.description_html">`
)[1];
const descriptionprocessed1 = descriptionraw.split("</div>")[0];
description = toMarkdown(descriptionprocessed1);
const match = questionPage.match(
/\s*window\.metacData\.question = (.+);\s*/
);
if (!match) {
throw new Error("metacData not found");
}
description = JSON.parse(match[1]).description;
}
return {