From 1e13938e3f1e3bc3b17085904f0f7ec0305c69c6 Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 4 Dec 2020 13:01:09 +0800 Subject: [PATCH 1/4] add time --- cmds/get.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmds/get.js b/cmds/get.js index 6f740d3..29c6839 100644 --- a/cmds/get.js +++ b/cmds/get.js @@ -17,6 +17,14 @@ const getStock = async (args) => { spinner.stop() // clear() + var date = new Date(); + Y = date.getFullYear() + '-'; + M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; + D = date.getDate() < 10 ? '0'+(date.getDate())+'T' : date.getDate()+'T'; + h = date.getHours() < 10 ? '0'+(date.getHours())+':' : date.getHours()+':'; + m = date.getMinutes() < 10 ? '0'+(date.getMinutes())+':' : date.getMinutes()+':'; + s = date.getSeconds() < 10 ? '0'+(date.getSeconds()) : date.getSeconds(); + console.log(Y+M+D+h+m+s); console.log(tabulate(['名称', '代码', '最新', '涨幅'])) stocks.forEach((item, index) => { const stockInfo = parse(codes[index], item) @@ -44,4 +52,4 @@ const getStock = async (args) => { } } -module.exports = getStock \ No newline at end of file +module.exports = getStock From 6892fd598dd6d4b316ccdc43755cad3d79709324 Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 10 Dec 2020 12:13:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=88=90=E4=BA=A4?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmds/get.js | 2 +- utils/parse.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmds/get.js b/cmds/get.js index 29c6839..974901a 100644 --- a/cmds/get.js +++ b/cmds/get.js @@ -25,7 +25,7 @@ const getStock = async (args) => { m = date.getMinutes() < 10 ? '0'+(date.getMinutes())+':' : date.getMinutes()+':'; s = date.getSeconds() < 10 ? '0'+(date.getSeconds()) : date.getSeconds(); console.log(Y+M+D+h+m+s); - console.log(tabulate(['名称', '代码', '最新', '涨幅'])) + console.log(tabulate(['名称', '代码', '最新', '涨幅', '成交量'])) stocks.forEach((item, index) => { const stockInfo = parse(codes[index], item) diff --git a/utils/parse.js b/utils/parse.js index a0c96be..9f2f50c 100644 --- a/utils/parse.js +++ b/utils/parse.js @@ -7,7 +7,8 @@ module.exports = (code, info) => { const last = arr[2] const now = arr[3] const change = ((now - last) / last) * 100 - return [name, code, now, change.toFixed(2)] + const number = arr[8]/1000000 + return [name, code, now, change.toFixed(2), number.toFixed(2)+'万手'] } if(code.startsWith('hk')) { const name = arr[1] @@ -21,4 +22,4 @@ module.exports = (code, info) => { return [name, code, now, change] } return ['', code, '', ''] -} \ No newline at end of file +} From b2dad9b419772ce6838c693473033671e26ff5c6 Mon Sep 17 00:00:00 2001 From: Timo Date: Sat, 29 Jan 2022 10:33:58 +0800 Subject: [PATCH 3/4] update --- cmds/get.js | 1 + package.json | 49 +++++++++++++++++++++++++++++++++++++++++-------- utils/parse.js | 1 + 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/cmds/get.js b/cmds/get.js index 974901a..12403a8 100644 --- a/cmds/get.js +++ b/cmds/get.js @@ -25,6 +25,7 @@ const getStock = async (args) => { m = date.getMinutes() < 10 ? '0'+(date.getMinutes())+':' : date.getMinutes()+':'; s = date.getSeconds() < 10 ? '0'+(date.getSeconds()) : date.getSeconds(); console.log(Y+M+D+h+m+s); + // console.log(tabulate(['名称', '代码', '最新', '涨幅'])) console.log(tabulate(['名称', '代码', '最新', '涨幅', '成交量'])) stocks.forEach((item, index) => { const stockInfo = parse(codes[index], item) diff --git a/package.json b/package.json index 4ac950e..71deb3f 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,56 @@ { - "name": "stocki", - "version": "1.0.2", - "main": "index.js", - "author": "liu", - "license": "MIT", + "_from": "stocki", + "_id": "stocki@1.0.2", + "_inBundle": false, + "_integrity": "sha512-JleN4EeEfdbie0jms02NR2NKUF0b1xYV/5gjp2qQcNYDCi4+zS9U/pjgSHEOfC8jR8ac1zMbZH5N2UheVl9RFQ==", + "_location": "/stocki", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "stocki", + "name": "stocki", + "escapedName": "stocki", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/stocki/-/stocki-1.0.2.tgz", + "_shasum": "2920a57ef4276695e1b03dc16badfe358fd3d6fe", + "_spec": "stocki", + "_where": "/usr/lib/node_modules/stocki/bin", + "author": { + "name": "liu" + }, "bin": { "stock": "bin/stock" }, + "bugs": { + "url": "https://github.com/jeezliu/stock-cli/issues" + }, + "bundleDependencies": false, "dependencies": { "axios": "^0.19.0", "chalk": "^2.4.2", "configstore": "^5.0.0", "iconv-lite": "^0.5.0", - "minimist": "^1.2.3", + "minimist": "^1.2.0", "ora": "^3.4.0", "word-width": "^1.0.1" }, + "deprecated": false, + "description": "Stocki 命令行程序查看股票价格。关注股票后,stock star 命令即可打印出关注股票的最新价格。", + "homepage": "https://github.com/jeezliu/stock-cli#readme", + "license": "MIT", + "main": "index.js", + "name": "stocki", "repository": { "type": "git", - "url": "https://github.com/jeezliu/stock-cli" - } + "url": "git+https://github.com/jeezliu/stock-cli.git" + }, + "version": "1.0.2" } diff --git a/utils/parse.js b/utils/parse.js index 9f2f50c..863db8e 100644 --- a/utils/parse.js +++ b/utils/parse.js @@ -7,6 +7,7 @@ module.exports = (code, info) => { const last = arr[2] const now = arr[3] const change = ((now - last) / last) * 100 + //return [name, code, now, change.toFixed(2)] const number = arr[8]/1000000 return [name, code, now, change.toFixed(2), number.toFixed(2)+'万手'] } From c5f9dc627fb9d04664866af9f7d2eae870b5751d Mon Sep 17 00:00:00 2001 From: Timo Date: Sat, 29 Jan 2022 10:41:34 +0800 Subject: [PATCH 4/4] add referer --- utils/fetch.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/fetch.js b/utils/fetch.js index 15587ea..743611b 100644 --- a/utils/fetch.js +++ b/utils/fetch.js @@ -6,6 +6,7 @@ module.exports = async (codes = []) => { const results = await axios({ method: 'get', url: 'http://hq.sinajs.cn/list=' + codes.join(','), + headers: {Referer: 'https://www.sina.com.cn'}, responseType: 'stream' }) @@ -24,4 +25,4 @@ module.exports = async (codes = []) => { resolve(resArr) }) }) -} \ No newline at end of file +}