This file contains hidden or 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 request = require('request'); | |
var extractLinksStream = extractStream.bind(null, /<a.*?href="(.*?)".*?>(.*?)<\/a>/gi); | |
request(process.argv[2]).pipe(extractLinksStream(function(found) { | |
var hrefs = found.map(function(item) { return item[1]; }); // Extract 1st capture | |
console.log(hrefs); | |
})); | |
This file contains hidden or 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 concat = require('concat-stream'); | |
http.get(process.argv[2], function(res) { | |
res.pipe(concat(function(buf) { | |
var html = buf.toString(); | |
var re = /<a.*?href="(.*?)".*?>/gi; | |
var links = []; | |
var matches; | |
while(matches = re.exec(html)) { |
This file contains hidden or 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 fs = require('fs'); | |
var localStore = require('./local-store'); | |
var store = new localStore.Store({ | |
path: '/var/data', | |
bucket: 'test' | |
}); | |
var data = fs.readFileSync('/etc/passwd'); |
This file contains hidden or 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
// | |
// middleware module | |
// | |
module.exports.reroute = function(url, func) { | |
return function(req, res, next) { | |
if(req.url.split('?', 1).pop() === url) { | |
req.url = func(req, res); | |
req.authorized = true; | |
} | |
next(); |
NewerOlder