#author("2019-12-01T13:16:40+00:00","","")
#mynavi(Node.js)
#setlinebreak(on);
* 目次 [#k50d61ee]
#contents
- 関連
-- [[Node.js]]
* 準備 [#j65992af]
#html(<div class="pl10">)
作業用ディレクトリの作成、必要なライブラリのインストール
#myterm2(){{
mkdir sample
cd sample
npm install request --save
npm install jquery --save
npm install jsdom --save
}}
#html(</div>)
* 実装 [#a0e832d5]
#html(<div class="pl10">)
sample.js
#mycode2(){{
const jquery = require("jquery");
const request = require("request");
const jsdom = require("jsdom");
var options = {
url: "https://xxxxx.xxxxx.xxxxx/",
method: "GET",
headers: {"Content-Type": "text/html"}
}
request(options, function (error, response, body) {
const dom = new jsdom.JSDOM(body);
const $ = (jquery)(dom.window);
$("body").find("dl ul li").each(function(){
console.log($(this).text());
});
});
}}
#html(</div>)
* 実行 [#sa11f6a5]
#html(<div class="pl10">)
#myterm2(){{
node sample.js
}}
#html(</div>)