/* Imports */ import axios from "axios"; import fs from "fs"; import { average } from "../../utils"; import { Platform } from "./"; const platformName = "givewellopenphil"; /* Support functions */ async function fetchPage(url: string): Promise { const response = await axios({ url: url, method: "GET", headers: { "Content-Type": "text/html", }, }).then((res) => res.data); return response; } /* Body */ async function main1() { let rawdata = fs.readFileSync("./input/givewellopenphil-urls.txt"); let data = rawdata .toString() .split("\n") .filter((url) => url != ""); // console.log(data) let results = []; for (let url of data) { // console.log(url) let page = await fetchPage(url); // Title let titleraw = page.split('')[0]; // Description let internalforecasts = page .split(" section.includes("Internal forecast") || section.includes("internal forecast") ); let description = "

({ ...datum, platform: platformName, // timestamp: new Date("2021-02-23"), })); return dataWithDate; }, calculateStars(data) { let nuno = () => 2; let eli = () => null; let misha = () => null; let starsDecimal = average([nuno()]); //, eli(), misha()]) let starsInteger = Math.round(starsDecimal); return starsInteger; }, };