【发布时间】:2021-08-17 02:25:57
【问题描述】:
如何获取自 github 存储库中上次更新以来经过的时间。我也想获得主要语言。 Picture of what i mean
我想要这些数据,以便能够在其他网站上使用它
我想过用 JS 来做,查看“id”和“class”标签,但我在 github web 上找到了这段代码:
<li class="col-12 d-flex width-full py-4 border-bottom color-border-secondary private source" itemprop="owns" itemscope itemtype="http://schema.org/Code">
<div class="col-10 col-lg-9 d-inline-block">
<div class="d-inline-block mb-1">
<h3 class="wb-break-all">
<a href="/nameRepo" itemprop="name codeRepository" >nameRepo</a>
</h3>
</div>
<div>
<p class="col-9 d-inline-block color-text-secondary mb-2 pr-4" itemprop="description">
Description
</p>
</div>
<div class="f6 color-text-secondary mt-2">
<span class="ml-0 mr-3">
<span class="repo-language-color" style="background-color: #f1e05a"></span>
<span itemprop="programmingLanguage">JavaScript</span>
</span>
Updated <relative-time datetime="2021-05-27T08:02:25Z" class="no-wrap">May 27, 2021</relative-time>
</div>
</div>
我意识到这是不可行的,即使可行,也根本不实用。
我认为也许可以使用“ssh”的 API,但这也不能说服我,因为我不想要一个不断消耗这些资源的网站。
你可以集思广益,没有任何问题
【问题讨论】:
-
日期可以这样格式化:momentjs
document.getElementById(id).innerHTML = 'Updated on ' + dateMoment.fromNow(true);document.getElementById(id).innerHTML = dateMoment.format("[Updated on] D MMM");document.getElementById(id).innerHTML = dateMoment.format("[Updated on] D MMM YYYY");
标签: javascript jquery ajax git github