db and image stuff
This commit is contained in:
parent
39d4c5aa41
commit
1b1364e71f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/node_modules/
|
@ -16,6 +16,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"lodash": "^3.10.0",
|
||||
"rss-braider": "^1.0.0"
|
||||
"rss-braider": "^1.0.0",
|
||||
"sqlite3": "^3.0.9"
|
||||
}
|
||||
}
|
||||
|
100
paleo-test.js
100
paleo-test.js
@ -4,8 +4,11 @@ var RssBraider = require('rss-braider'),
|
||||
read = require('fs').readFileSync,
|
||||
join = require('path').join,
|
||||
str = read(join(__dirname, '/templates/rss.ejs'), 'utf8'),
|
||||
sqlite3 = require('sqlite3').verbose(),
|
||||
feeds = {};
|
||||
|
||||
var db = new sqlite3.Database(__dirname + '/images.db');
|
||||
|
||||
// Pull feeds from config files: ,
|
||||
// feeds.simple_test_feed = require("./config/feed").feed;
|
||||
// Or define in-line
|
||||
@ -21,8 +24,44 @@ feeds.simple_test_feed = {
|
||||
"sources" : [
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count" : 1,
|
||||
"feed_url" : "http://feeds.feedburner.com/PaleoPlan"
|
||||
"count": 100,
|
||||
"feed_url": "http://feeds.feedburner.com/PaleoPlan"
|
||||
},
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count": 100,
|
||||
"feed_url": "http://nomnompaleo.com/rss"
|
||||
},
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count": 100,
|
||||
"feed_url": "http://thepaleodiet.com/feed/"
|
||||
},
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count": 100,
|
||||
"feed_url": "http://paleoleap.com/feed/"
|
||||
},
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count": 100,
|
||||
"feed_url": "http://ultimatepaleoguide.com/feed/"
|
||||
},
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count": 100,
|
||||
"feed_url": "http://elanaspantry.com/feed/"
|
||||
}
|
||||
,
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count": 100,
|
||||
"feed_url": "http://feeds.feedburner.com/Paleomg-PaleoRecipes"
|
||||
},
|
||||
{
|
||||
/* "name" : "JobServe",*/
|
||||
"count": 100,
|
||||
"feed_url": "http://civilizedcavemancooking.com/feed/"
|
||||
}
|
||||
]
|
||||
};
|
||||
@ -46,16 +85,53 @@ rss_braider.logger.level('off');
|
||||
}
|
||||
|
||||
var j = JSON.parse(data);
|
||||
var ejsOutput = ejs.compile(str)(j);
|
||||
|
||||
console.log(j);
|
||||
console.log(ejsOutput);
|
||||
fs.writeFile(__dirname + "/html/paleo.html", ejsOutput, function(err) {
|
||||
//fs.writeFile(__dirname + "/html/paleo.json", data, function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
console.log("The file was saved!");
|
||||
});
|
||||
j.items.forEach(function (obj, index) {
|
||||
// console.log(obj); // logs "3", "5", "7"
|
||||
// console.log(index); // logs "0", "1", "2"
|
||||
|
||||
var desc = obj.description;
|
||||
|
||||
var imgRegEx = /<img[^>]+src="([^">]+)"/;
|
||||
var myArray = imgRegEx.exec(desc) || [];
|
||||
|
||||
if (myArray.length > 0)
|
||||
{
|
||||
console.log('Length: ' + myArray.length);
|
||||
console.log(myArray[0]);
|
||||
console.log(myArray[1]);
|
||||
console.log('- - -');
|
||||
}
|
||||
});
|
||||
|
||||
// var ejsOutput = ejs.compile(str)(j);
|
||||
|
||||
//console.log(j);
|
||||
// console.log(ejsOutput);
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// grabbing images
|
||||
<img[^>]+src="([^">]+)"
|
||||
|
||||
|
||||
|
||||
var fs = require('fs');
|
||||
var request = require('request');
|
||||
// Or with cookies
|
||||
// var request = require('request').defaults({jar: true});
|
||||
|
||||
request.get({url: 'https://someurl/somefile.torrent', encoding: 'binary'}, function (err, response, body) {
|
||||
fs.writeFile("/tmp/test.torrent", body, 'binary', function(err) {
|
||||
if(err)
|
||||
console.log(err);
|
||||
else
|
||||
console.log("The file was saved!");
|
||||
});
|
||||
});
|
||||
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user