This commit is contained in:
ssyyhhrr
2023-01-01 13:01:07 +00:00
parent 0c11ab534f
commit 1f7487b7c6

4
app.js
View File

@@ -120,6 +120,7 @@ async function updateDrivers() {
drivers = {} drivers = {}
for (let i = 2000; i <= year; i++) { for (let i = 2000; i <= year; i++) {
console.log(`Scraping F1 ${i} Season...`) console.log(`Scraping F1 ${i} Season...`)
try {
await axios.get(`http://ergast.com/api/f1/${i}/driverStandings.json?limit=1000`).then(res => { await axios.get(`http://ergast.com/api/f1/${i}/driverStandings.json?limit=1000`).then(res => {
res.data.MRData.StandingsTable.StandingsLists[0].DriverStandings.forEach(driver => { res.data.MRData.StandingsTable.StandingsLists[0].DriverStandings.forEach(driver => {
if (driver.Driver.driverId in drivers) { if (driver.Driver.driverId in drivers) {
@@ -140,6 +141,9 @@ async function updateDrivers() {
} }
}) })
}) })
} catch (e) {
if (i !== year) throw ""
}
} }
if (fs.existsSync("assets/drivers.json")) { if (fs.existsSync("assets/drivers.json")) {