Skip to content

Instantly share code, notes, and snippets.

@nrm176
Created December 4, 2018 08:51
Show Gist options
  • Save nrm176/b360ca9f18b17b6bf2bdce1fb3de82f7 to your computer and use it in GitHub Desktop.
Save nrm176/b360ca9f18b17b6bf2bdce1fb3de82f7 to your computer and use it in GitHub Desktop.
BoJの桜レポート
const axios = require("axios");
var HTMLParser = require('fast-html-parser');
const jsdom = require("jsdom");
var iconv = require('iconv-lite');
const { JSDOM } = jsdom;


const URL = 'https://www.boj.or.jp/research/brp/rer/index.htm'
const getData = async (url) => {
    const response = await axios.get(url)
    return response.data;
}

(async () => {
    const d = await getData(URL);
    var root = await HTMLParser.parse(d)
    const dom = new JSDOM(d,
        { includeNodeLocations: true }
    );

    const document = dom.window.document;
    const bodyEl = document.body; // implicitly created
    const pEl = Array.from(document.querySelectorAll('table.js-tbl tr')).map((e)=>{return e.textContent})

    console.log(pEl)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment