mirror of
https://gitlab.silvrtree.co.uk/martind2000/old-silvrgit.git
synced 2025-01-10 21:05:09 +00:00
45 lines
1003 B
JavaScript
45 lines
1003 B
JavaScript
/**
|
|
* Created by Martin on 15/02/2016.
|
|
*/
|
|
var http = require('http'), request = require('request'), util = require('util');
|
|
var jsonfile = require('jsonfile');
|
|
var log4js = require('log4js');
|
|
var logger = log4js.getLogger();
|
|
var to_json = require('xmljson').to_json;
|
|
|
|
require('sugar-date');
|
|
|
|
|
|
var file = __dirname + '/' + 'cal.json';
|
|
|
|
function saveData(v) {
|
|
jsonfile.writeFileSync(file, v);
|
|
}
|
|
|
|
module.exports = {
|
|
getSwedishWord: function (cb) {
|
|
|
|
var t= new Date(), ms = t.getTime();
|
|
|
|
|
|
url = ['http://wotd.transparent.com/rss/swedish-widget.xml?t=', ms].join('');
|
|
logger.info(url);
|
|
request(url, function (err, resp, body) {
|
|
if (err)
|
|
throw err;
|
|
|
|
logger.debug(body);
|
|
|
|
to_json(body, function (error, data) {
|
|
console.log(data);
|
|
if(typeof cb === 'function') {
|
|
cb(data);
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
};
|
|
|
|
//module.exports.getSwedishWord();
|