feat: Adapted metaforecast to work with the new Metaculus frontend.

This commit is contained in:
NunoSempere 2021-08-25 23:42:03 +02:00
parent b6b4252c72
commit b3678df9cd

View File

@ -44,6 +44,7 @@ async function fetchMetaculusQuestionDescription(slug) {
method: 'get', method: 'get',
url: "https://www.metaculus.com" + slug url: "https://www.metaculus.com" + slug
}).then(response => response.data) }).then(response => response.data)
// console.log(response)
return response return response
} catch (error) { } catch (error) {
console.log(`We encountered some error when attempting to fetch a metaculus page.`) console.log(`We encountered some error when attempting to fetch a metaculus page.`)
@ -78,10 +79,9 @@ export async function metaculus() {
(result.publish_time < now) && (result.publish_time < now) &&
(now < result.resolve_time) (now < result.resolve_time)
) { ) {
// console.log(result) await sleep(2000)
await sleep(5000)
let questionPage = await fetchMetaculusQuestionDescription(result.page_url) let questionPage = await fetchMetaculusQuestionDescription(result.page_url)
let descriptionraw = questionPage.split(`<div class="question__content">`)[1] let descriptionraw = questionPage.split(`<div class="content" ng-bind-html-compile="qctrl.question.description_html">`)[1] //.split(`<div class="question__content">`)[1]
let descriptionprocessed1 = descriptionraw.split("</div>")[0] let descriptionprocessed1 = descriptionraw.split("</div>")[0]
let descriptionprocessed2 = toMarkdown(descriptionprocessed1) let descriptionprocessed2 = toMarkdown(descriptionprocessed1)
let description = descriptionprocessed2 let description = descriptionprocessed2
@ -127,7 +127,7 @@ export async function metaculus() {
//"last_activity_time": result.last_activity_time, //"last_activity_time": result.last_activity_time,
}) })
if (Number(result.number_of_predictions) >= 10) { if (Number(result.number_of_predictions) >= 10) {
// console.log(interestingInfo) console.log(` ${interestingInfo.title}`)
all_questions.push(interestingInfo) all_questions.push(interestingInfo)
if(!j && (i % 20 == 0)){ if(!j && (i % 20 == 0)){
console.log(interestingInfo) console.log(interestingInfo)