这年头不缺算法, 就缺数据. 这两天花了很多时间在整API上, 整完之后自己用了一下还觉得真是挺方便的. 今天就突然想看一看自己是否给大家拖后腿了, 于是调用每日中文区微信群排行榜单的API, 刷刷拿着 NodeJs 练手:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | // @justyy var request = require("request") var url = "https://uploadbeta.com/api/steemit/wechat/?cached"; request({ url: url, json: true }, function (error, response, body) { if (!error && response.statusCode === 200) { var total = 0; var total_rep = 0; var total_sbd = 0; var total_steem = 0; var total_value = 0; var total_esp = 0; var total_vp = 0; var total_sp = 0; body.forEach(function(member) { total ++; total_rep += member['rep']; total_sbd += member['sbd']; total_steem += member['steem']; total_value += member['value']; total_esp += member['esp']; total_vp += member['vp']; total_sp += member['sp']; }); console.log("Total Members = " + total); console.log("Average Reputation = " + Math.round(total_rep / total * 100) / 100); console.log("Average SBD = " + Math.round(total_sbd / total * 100) / 100); console.log("Average Steem = " + Math.round(total_steem / total * 100) / 100); console.log("Average Effective SP = " + Math.round(total_esp / total * 100) / 100); console.log("Average SP = " + Math.round(total_sp / total * 100) / 100); console.log("Average Voting Power = " + Math.round(total_vp / total * 100) / 100); console.log("Average Account Value = " + Math.round(total_value / total * 100) / 100); } }) |
// @justyy var request = require("request") var url = "https://uploadbeta.com/api/steemit/wechat/?cached"; request({ url: url, json: true }, function (error, response, body) { if (!error && response.statusCode === 200) { var total = 0; var total_rep = 0; var total_sbd = 0; var total_steem = 0; var total_value = 0; var total_esp = 0; var total_vp = 0; var total_sp = 0; body.forEach(function(member) { total ++; total_rep += member['rep']; total_sbd += member['sbd']; total_steem += member['steem']; total_value += member['value']; total_esp += member['esp']; total_vp += member['vp']; total_sp += member['sp']; }); console.log("Total Members = " + total); console.log("Average Reputation = " + Math.round(total_rep / total * 100) / 100); console.log("Average SBD = " + Math.round(total_sbd / total * 100) / 100); console.log("Average Steem = " + Math.round(total_steem / total * 100) / 100); console.log("Average Effective SP = " + Math.round(total_esp / total * 100) / 100); console.log("Average SP = " + Math.round(total_sp / total * 100) / 100); console.log("Average Voting Power = " + Math.round(total_vp / total * 100) / 100); console.log("Average Account Value = " + Math.round(total_value / total * 100) / 100); } })
我是在WINDOWS 下用 sublime text 3 然后下载最新版的 NodeJS 来编写的. NodeJS 虽然是服务端的Javascript, 但是硬生生的被我拿来写些客户端的一些脚本.
需要使用 npm install request 来安装 request 包, 代码很清楚 不需要我再过多的解释了. 直接出结果:
1 2 3 4 5 6 7 8 9 | Total Members = 170 Average Reputation = 48.55 Average SBD = 224.4 Average Steem = 19.6 Average Effective SP = 18819.85 Average SP = 1579.47 Average Voting Power = 82.12 Average Account Value = 2462.17 [Finished in 1.1s] |
Total Members = 170 Average Reputation = 48.55 Average SBD = 224.4 Average Steem = 19.6 Average Effective SP = 18819.85 Average SP = 1579.47 Average Voting Power = 82.12 Average Account Value = 2462.17 [Finished in 1.1s]
你拖后腿了么? CN区一下子多了好多大鱼(包括代理SP), 一下子把ESP平均指标给拉了上去.
最后, 再广告一下:
- SteemIt 好友微信群排行榜
- SteemIt 好友微信群文章列表 RSS Feed
- SteemIt 编程 Geek 微信群, 请联系 @justyy 让我拉你入群.
需要入群者 请联系 @justyy 谢谢.
英文: Simple NodeJS Example to Show Average Scores in the Steemit-Wechat Group
强烈推荐
- 英国代购-畅购英伦
- TopCashBack 返现 (英国购物必备, 积少成多, 我2年来一共得了3000多英镑)
- Quidco 返现 (也是很不错的英国返现网站, 返现率高)
- 注册就送10美元, 免费使用2个月的 DigitalOcean 云主机(性价比超高, 每月只需5美元)
- 注册就送10美元, 免费使用4个月的 Vultr 云主机(性价比超高, 每月只需2.5美元)
- 注册就送10美元, 免费使用2个月的 阿里 云主机(性价比超高, 每月只需4.5美元)
- 注册就送20美元, 免费使用4个月的 Linode 云主机(性价比超高, 每月只需5美元) (折扣码: PodCastInit2022)
- PlusNet 英国光纤(超快, 超划算! 用户名 doctorlai)
- 刷了美国运通信用卡一年得到的积分 换了 485英镑
- 注册就送50英镑 – 英国最便宜最划算的电气提供商
- 能把比特币莱特币变现的银行卡! 不需要手续费就可以把虚拟货币法币兑换
微信公众号: 小赖子的英国生活和资讯 JustYYUK