Skip to content

Instantly share code, notes, and snippets.

@bright23
Created November 30, 2016 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bright23/a8958cc97c5f7f635f164ba23da4b7be to your computer and use it in GitHub Desktop.
Save bright23/a8958cc97c5f7f635f164ba23da4b7be to your computer and use it in GitHub Desktop.
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