mirror of
https://gitlab.silvrtree.co.uk/martind2000/old-silvrgit.git
synced 2025-01-10 23:35:08 +00:00
added tech history to today
This commit is contained in:
parent
1c84148af2
commit
17bb4114c3
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@
|
|||||||
# Example .gitignore files: https://github.com/github/gitignore
|
# Example .gitignore files: https://github.com/github/gitignore
|
||||||
/bower_components/
|
/bower_components/
|
||||||
/node_modules/
|
/node_modules/
|
||||||
|
.idea
|
||||||
|
/.idea
|
||||||
|
41
lib/today.js
41
lib/today.js
@ -4,6 +4,8 @@
|
|||||||
var http = require('http'), request = require('request'), cheerio = require('cheerio'), Forecast = require('forecast.io'), util = require('util'), UltraSES = require('ultrases'), cron = require('node-cron');
|
var http = require('http'), request = require('request'), cheerio = require('cheerio'), Forecast = require('forecast.io'), util = require('util'), UltraSES = require('ultrases'), cron = require('node-cron');
|
||||||
var jade = require('jade'), _ = require('lodash'), dateFormat = require('dateformat');
|
var jade = require('jade'), _ = require('lodash'), dateFormat = require('dateformat');
|
||||||
var jsonfile = require('jsonfile');
|
var jsonfile = require('jsonfile');
|
||||||
|
var log4js = require('log4js');
|
||||||
|
var logger = log4js.getLogger();
|
||||||
|
|
||||||
var todayCache = {
|
var todayCache = {
|
||||||
last: 0,
|
last: 0,
|
||||||
@ -66,6 +68,39 @@ module.exports = {
|
|||||||
res.render('pages/today', todayCache);
|
res.render('pages/today', todayCache);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTechHistory: function () {
|
||||||
|
var url, d, day, month, monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
||||||
|
|
||||||
|
d = new Date();
|
||||||
|
|
||||||
|
month = monthNames[d.getMonth()];
|
||||||
|
|
||||||
|
day = d.getDate();
|
||||||
|
|
||||||
|
url = ['http://www.computerhistory.org/tdih/', month, '/', day].join('');
|
||||||
|
logger.info(url);
|
||||||
|
request(url, function (err, resp, body) {
|
||||||
|
if (err)
|
||||||
|
throw err;
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
var tdihbody = $('#tdihbody');
|
||||||
|
|
||||||
|
var output = [];
|
||||||
|
|
||||||
|
tdihbody.find('.tdihevent > p').each(function (div) {
|
||||||
|
|
||||||
|
logger.info($(this));
|
||||||
|
var s = $(this).text();
|
||||||
|
if (s.indexOf('Today\'s recipe:') == -1) {
|
||||||
|
output.push(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
todayCache.data.history = todayCache.data.history.concat(output);
|
||||||
|
console.log(todayCache.data.history);
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
getHistory: function () {
|
getHistory: function () {
|
||||||
var url, d, day, month, monthNames = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
var url, d, day, month, monthNames = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
||||||
|
|
||||||
@ -76,6 +111,9 @@ module.exports = {
|
|||||||
day = d.getDate();
|
day = d.getDate();
|
||||||
|
|
||||||
url = ['http://www.bbc.co.uk/scotland/history/onthisday/', month, '/', day].join('');
|
url = ['http://www.bbc.co.uk/scotland/history/onthisday/', month, '/', day].join('');
|
||||||
|
|
||||||
|
todayCache.data.history = [];
|
||||||
|
|
||||||
console.log(url);
|
console.log(url);
|
||||||
request(url, function (err, resp, body) {
|
request(url, function (err, resp, body) {
|
||||||
if (err)
|
if (err)
|
||||||
@ -95,6 +133,7 @@ module.exports = {
|
|||||||
|
|
||||||
todayCache.data.history = output;
|
todayCache.data.history = output;
|
||||||
console.log(todayCache.data.history);
|
console.log(todayCache.data.history);
|
||||||
|
module.exports.getTechHistory();
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -235,6 +274,7 @@ setTimeout(function () {
|
|||||||
// console.log('Pre loading trains...');
|
// console.log('Pre loading trains...');
|
||||||
module.exports.getHistory();
|
module.exports.getHistory();
|
||||||
|
|
||||||
|
|
||||||
}, 25000);
|
}, 25000);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -257,3 +297,4 @@ cron.schedule('0 7 * * *', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.getHistory();
|
@ -9,6 +9,8 @@
|
|||||||
"htmlparser": "^1.7.7",
|
"htmlparser": "^1.7.7",
|
||||||
"jade": "^1.11.0",
|
"jade": "^1.11.0",
|
||||||
"jsonfile": "^2.2.3",
|
"jsonfile": "^2.2.3",
|
||||||
|
"lodash": "^4.3.0",
|
||||||
|
"log4js": "^0.6.31",
|
||||||
"mammoth": "^0.3.25-pre.1",
|
"mammoth": "^0.3.25-pre.1",
|
||||||
"request": "^2.67.0",
|
"request": "^2.67.0",
|
||||||
"simple-weather": "^1.2.2",
|
"simple-weather": "^1.2.2",
|
||||||
@ -16,7 +18,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "3.x",
|
"express": "3.x",
|
||||||
"lodash": "^4.3.0",
|
|
||||||
"node-cron": "^1.0.0",
|
"node-cron": "^1.0.0",
|
||||||
"scrape": "^0.2.3",
|
"scrape": "^0.2.3",
|
||||||
"ultrases": "^0.1.3",
|
"ultrases": "^0.1.3",
|
||||||
|
Loading…
Reference in New Issue
Block a user