From 7c388e6aa2b54a1ef07048d931252bc3e359f7a8 Mon Sep 17 00:00:00 2001
From: Bruce Zheng <46187947+mrbruce516@users.noreply.github.com>
Date: Mon, 30 Nov 2020 03:13:14 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=89=B9=E6=96=AF?=
=?UTF-8?q?=E6=8B=89=E7=B3=BB=E7=BB=9F=E6=9B=B4=E6=96=B0=20(#6275)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/program-update.md | 6 ++++++
lib/router.js | 3 +++
lib/routes/tesla/update.js | 42 ++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
create mode 100644 lib/routes/tesla/update.js
diff --git a/docs/program-update.md b/docs/program-update.md
index f3cf364ca3..d69fe1cbe1 100644
--- a/docs/program-update.md
+++ b/docs/program-update.md
@@ -314,6 +314,12 @@ pageClass: routes
+## 特斯拉系统更新
+
+### 版本详细信息
+
+
+
## 腾讯柠檬 Lab
### 柠檬精选 Mac Apps
diff --git a/lib/router.js b/lib/router.js
index 52dba550e4..5f2ca3ae2f 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -3537,4 +3537,7 @@ router.get('/youdao/latest', require('./routes/youdao/latest'));
router.get('/yinxiang/note', require('./routes/yinxiang/note'));
router.get('/yinxiang/card/:id?', require('./routes/yinxiang/card'));
+// 特斯拉系统更新
+router.get('/tesla', require('./routes/tesla/update'));
+
module.exports = router;
diff --git a/lib/routes/tesla/update.js b/lib/routes/tesla/update.js
new file mode 100644
index 0000000000..979b06d98e
--- /dev/null
+++ b/lib/routes/tesla/update.js
@@ -0,0 +1,42 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+
+module.exports = async (ctx) => {
+ const response = await got({
+ method: 'get',
+ url: 'https://www.notateslaapp.com/zh-cn',
+ headers: {
+ Referer: 'https://www.notateslaapp.com/zh-cn',
+ },
+ });
+
+ const data = response.data;
+
+ const $ = cheerio.load(data);
+ const list = $('article[id]');
+
+ ctx.state.data = {
+ title: '特斯拉系统更新',
+ link: 'https://www.notateslaapp.com/zh-cn',
+ description: '特斯拉系统更新 - 最新发布',
+ item:
+ list &&
+ list
+ .map((index, item) => {
+ item = $(item);
+ const targetDate = item
+ .find('.date')
+ .text()
+ .replace(/[\u4e00-\u9fa5]/g, '-')
+ .replace(/\s/g, '')
+ .match(/(\d{4}-\d{1,2}-\d{1,2})/);
+ return {
+ title: item.find('.container h1').text(),
+ description: item.find('.notes-container').text() + '
',
+ pubDate: targetDate[0],
+ link: 'https://www.notateslaapp.com' + item.find('.selector-container-notes a').attr('href'),
+ };
+ })
+ .get(),
+ };
+};