Code Monkey home page Code Monkey logo

aqicn's Introduction

aqicn

Build Status David Dependencies David Dependencies npm npm

一个 aqicn.org 的非官方 API。

安装

npm install aqicn --save

使用

加载模块:

var aqicn = require('aqicn');

获取指定城市的全部 AQI 值:

aqicn.getAQIs('beijing', 'cn', function (err, res) {
  console.log(res);
};

输出:

{
  city: 'beijing',
  time: '2016-01-21T21:00:00+09:00',
  pm25: 212,
  pm10: 95,
  o3: 4,
  no2: 37,
  so2: 14,
  co: 28,
  aqi: 212,
  level: {
    value: 5,
    name: '重度污染',
    implication: '心脏病和肺病患者症状显著加剧,运动耐受力降低,健康人群普遍出现症状',
    statement: '儿童、老年人及心脏病、肺病患者应停留在室内,停止户外运动,一般人群减少户外运动'
  }
}

获取指定城市的某一种 AQI 值:

aqicn.getAQIByName('beijing', 'pm25', function (err, res) {
  console.log(res);
};

输出:

{
  city: 'beijing',
  value: 212,
  time: '2016-01-21T21:00:00-09:00'
}

已知 AQI 等级查询对应的信息:

var lv = 5;
var lang = 'cn';
aqicn.info.level[lv].name[lang];   // AQI 级别名
aqicn.info.level[lv].implication[lang];   // 对健康的影响
aqicn.info.level[lv].statement[lang];   // 建议采取的措施

问题

有没有历史查询功能?

无,但你可以自己抓取。

你怎么能用 HTTP 请求暴力抓取数据?这是不对的!

我方了。

你的代码为什么这样糟糕?

太好了!快快联系我,告诉我到底哪里糟糕!

感谢

aqicn.org 网站 - 提供数据

Node.jsrequestcheerio - 提供技术

GNU Emacs - 提供开发环境

以及其他我所用到的工具、模块的作者们。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.