This repository has been archived on 2021-06-30. You can view files and clone it, but cannot push or open issues or pull requests.
trendogate_scraper/index.ts

35 lines
915 B
TypeScript
Raw Normal View History

2020-03-05 15:30:20 +00:00
"use strict";
const SITE_URL = "https://trendogate.com/";
const NUMBER_OF_DAYS = 100;
const USA_ID = 23424977;
// https://trendogate.com/placebydate/23424977/2015-04-01
// Topic | Date | Position
// SO: https://stackoverflow.com/questions/4345045/javascript-loop-between-date-ranges/14655646
const now: Date = new Date();
let tmp : Date = now;
let days: Array<Date> = [];
for (let i = 0; i < 100; i++) {
tmp = new Date(tmp.getDate() - 1);
days.push(tmp);
}
function getNewDateURL(date: Date): String {
let year: Number = date.getFullYear();
let month: Number = date.getMonth();
let day: Number = date.getDay();
let monthFmt: String;
let dayFmt: String;
if (month < 10) monthFmt = `0${month}`;
else monthFmt = `${month}`;
if (day < 10) dayFmt = `0${day}`;
else dayFmt = `${day}`;
return `${SITE_URL}/placebydate/${USA_ID}/${year}-${monthFmt}-${dayFmt}`;
}