简体   繁体   English

从 Github 文件夹下载最新文件

[英]Download latest file from Github folder

how would I download the latest file that is uploaded to some Github repo in a particular folder?我将如何下载上传到特定文件夹中某些 Github 存储库的最新文件? I am using Node.js with cron job to download the file, but I need to get the fresh file every day.我正在使用带有 cron 作业的 Node.js 来下载文件,但我每天都需要获取新文件。

This is the repo if anyone is interested: https://github.com/CSSEGISandData/COVID-19如果有人感兴趣,这是回购: https : //github.com/CSSEGISandData/COVID-19

Previous day's reports are published every day, so get the latest file using the date.每天都会发布前一天的报告,因此请使用日期获取最新文件。

 function getDate() { const yesterday = new Date(); yesterday.setDate(yesterday.getDate() - 1); let dd = yesterday.getDate(); let mm = yesterday.getMonth() + 1; const yyyy = yesterday.getFullYear(); if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm; } return `${mm}-${dd}-${yyyy}` } const baseUrl = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/'; function getLatestDownloadUrl() { return `${baseUrl}${getDate()}.csv`; } console.log(getLatestDownloadUrl());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM