From 26dc65132b1375cf85c2833afc062e7e159e9360 Mon Sep 17 00:00:00 2001 From: paoda Date: Tue, 17 Mar 2020 04:38:30 -0300 Subject: [PATCH] Updated Constraints of the Scraper No longer just the past 200 or so days. Now the scraper gets all trending data from 2015-03-01 to once a week. --- index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 9489b85..ee87a91 100644 --- a/index.ts +++ b/index.ts @@ -4,6 +4,7 @@ * @license MIT * @version 2020.03.17 */ + import { addDays, format } from 'date-fns'; import cheerio from 'cheerio'; import axios from 'axios'; @@ -18,13 +19,13 @@ const WAIT = 500; // in ms // e.g https://trendogate.com/placebydate/23424977/2015-04-01 // Topic | Position | Date -const now: Date = new Date(); -let tmp : Date = now; +const goal: Date = new Date(2015, 2, 1); // 2 is March because Month is 0-indexed (why?) +let tmp : Date = new Date(); let days: Array = []; -for (let i = 0; i < NUMBER_OF_DAYS; i++) { - tmp = addDays(tmp, -1); +while (tmp >= goal) { days.push(tmp); + tmp = addDays(tmp, -7); } async function scrapeData() {