tweak: change user agent for good judgment forecasts

This commit is contained in:
NunoSempere 2022-02-04 15:20:39 -05:00
parent 20c9c820fb
commit c064b23c9e

View File

@ -9,7 +9,7 @@ import { upsert } from "../utils/mongo-wrapper.js";
/* Definitions */ /* Definitions */
let endpoints = [ let endpoints = [
"https://goodjudgment.io/superforecasts/", "https://goodjudgment.io/superforecasts/",
"https://goodjudgment.io/economist/", // "https://goodjudgment.io/economist/",
]; ];
String.prototype.replaceAll = function replaceAll(search, replace) { String.prototype.replaceAll = function replaceAll(search, replace) {
return this.split(search).join(replace); return this.split(search).join(replace);
@ -21,7 +21,14 @@ String.prototype.replaceAll = function replaceAll(search, replace) {
export async function goodjudgment() { export async function goodjudgment() {
let results = []; let results = [];
for (let endpoint of endpoints) { for (let endpoint of endpoints) {
let content = await axios.get(endpoint).then((query) => query.data); let content = await axios
.get(endpoint, {
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
},
})
.then((query) => query.data);
let jsonTable = Tabletojson.convert(content, { stripHtmlFromCells: false }); let jsonTable = Tabletojson.convert(content, { stripHtmlFromCells: false });
jsonTable.shift(); // deletes first element jsonTable.shift(); // deletes first element
jsonTable.pop(); // deletes last element jsonTable.pop(); // deletes last element