LoginSignup
0
0

More than 5 years have passed since last update.

nuroモバイルのデータ使用量を取得する

Last updated at Posted at 2018-11-30

毎回ログインしてWebページ上で確認するのは面倒くさいのでデータ使用量を取得するコードを書いた。
定期的にデータを集めてSlack投稿したりメトリクス作ったりするつもり。


var client = require("cheerio-httpcli");

const PHONE_NUMBER = process.env.PHONE_NUMBER;
const PASSWORD = process.env.PASSWORD;

const nuroSite = "https://mobile.nuro.jp/mobile_contract/u/login/";

client.fetch(nuroSite, (err, $) => {
  $("#simNumber").val(PHONE_NUMBER);
  $("#simPassword").val(PASSWORD);

  $("#simSubmit").click((err, $) => {
    const result = {};
    const zyokyoBlock = $(".zyokyoBlock");
    result[zyokyoBlock.find("li > ul > li > p.title").text()] = parseInt(
      zyokyoBlock
        .find("li > ul > li > p.data > .yen")
        .text()
        .replace(",", "")
    );
    zyokyoBlock.find(".kanou").each(function(idx) {
      result[
        $(this)
          .find("p.title")
          .text()
          .replace(",", "")
      ] = parseInt(
        $(this)
          .find("p.data > .yen")
          .text()
          .replace(",", "")
      );
    });

    zyokyoBlock.find(".siyou").each(function(idx) {
      result[
        $(this)
          .find("p.title")
          .text()
          .replace(",", "")
      ] = parseInt(
        $(this)
          .find("p.data > .yen")
          .text()
          .replace(",", "")
      );
    });

    // Slack通知なり何でもかんでもする
    console.log(result);
  });
});

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0