Created
November 30, 2016 01:51
-
-
Save bright23/a8958cc97c5f7f635f164ba23da4b7be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
var url = 'http://itunes.apple.com/jp/rss/topsongs/limit=100/xml'; | |
var rss = ''; | |
var req = http.get(url, function (res) { | |
// テキストファイルの場合は、エンコード指定は重要! | |
res.setEncoding('utf8'); | |
// データを受け取るたびに、文字列を追加 | |
res.on('data', function (xml) { | |
rss += xml; | |
}); | |
// ファイルのダウンロードが終わるとendイベントが呼ばれる | |
res.on('end', function () { | |
console.log('finish loading rss feed.'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment