Merge pull request #801 from pasindud/master

Wappalyzer NPM Driver fix package.json typo, updated tests, added jshint, and fix multiple req
main
Elbert Alias 10 years ago
commit f9f1006290

@ -0,0 +1,14 @@
root = true
[*]
indent_style = tab
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,py}]
charset = utf-8
[*.py]
indent_style = space
indent_size = 4

@ -0,0 +1,5 @@
{
"node" : true,
"browser" : "false",
"predef": []
}

@ -1,83 +1,86 @@
'use strict';
var request = require('request'); var request = require('request');
var fs = require("fs"); var fs = require('fs');
var path =require("path"); var path = require('path');
//TODO //TODO
exports.detectFromHTML = function (options) {}; exports.detectFromHTML = function(options) {};
exports.detectFromUrl = function (options,cb) { exports.detectFromUrl = function(options, cb) {
var url = options.url;
if (options.debug ) { var url = options.url;
console.log("Fetching the page");
};
getHTMLFromUrl(url,function (err,data) { if (options.debug) {
if (err) { console.log('Fetching the page');
cb(err,null) }
}else{
runWrappalyer(options,data, function (err,detected,appInfo) { getHTMLFromUrl(url, function(err, data) {
cb(null,detected,appInfo) if (err || data === null) {
}); cb(err, null);
} } else {
}) runWrappalyer(options, data, function(err, detected, appInfo) {
} cb(null, detected, appInfo);
});
}
});
};
function getHTMLFromUrl (url,cb) { function getHTMLFromUrl(url, cb) {
request(url, function(error, response, body) { request(url, function(error, response, body) {
if (!error && response.statusCode == 200) { if (!error && response.statusCode == 200) {
var data = { var data = {
html: body, html: body,
url: url, url: url,
headers: response headers: response
}; };
cb(null,data); cb(null, data);
}else{ } else {
cb(error,null) cb(error, null);
} }
}); });
} }
function getAppsJson(cb) { function getAppsJson(cb) {
fs.readFile(path.resolve(__dirname, 'apps.json'), 'utf8', function(err, data) { fs.readFile(path.resolve(__dirname, 'apps.json'), 'utf8', function(err, data) {
if (err) throw err; if (err) throw err;
return cb(null, JSON.parse(data)) return cb(null, JSON.parse(data));
}); });
} }
function runWrappalyer(options,data,cb) { function runWrappalyer(options, data, cb) {
var debug = options.debug || false; var debug = options.debug || false;
var wappalyzer = require("./wappalyzer").wappalyzer; var wappalyzer = require('./wappalyzer').wappalyzer;
getAppsJson(function(err, apps) { getAppsJson(function(err, apps) {
var w = wappalyzer; var w = wappalyzer;
w.driver = { w.driver = {
log: function(args) { log: function(args) {
if (debug) { if (debug) {
console.log(args.message); console.log(args.message);
}; }
}, },
init: function() { init: function() {
w.categories = apps.categories; w.categories = apps.categories;
w.apps = apps.apps; w.apps = apps.apps;
}, },
displayApps: function() { displayApps: function() {
var app,url = Object.keys(w.detected)[0]; var app, url = Object.keys(w.detected)[0];
var detectedApps = []; var detectedApps = [];
for (app in w.detected[url]) {
detectedApps.push(app);
if (debug) { for (app in w.detected[url]) {
console.log(app); detectedApps.push(app);
};
}; if (debug) {
cb(null,detectedApps,w.detected[url]) console.log(app);
} }
} }
w.init(); cb(null, detectedApps, w.detected[url]);
w.analyze(options.hostname,options.url, data) }
}); };
} w.init();
w.detected = [];
w.analyze(options.hostname, options.url, data);
});
}

@ -1,6 +1,6 @@
{ {
"name": "wrappalyzer", "name": "wappalyzer",
"version": "2.0.0", "version": "2.0.2",
"description": "NPM Module that uncovers the technologies used on websites", "description": "NPM Module that uncovers the technologies used on websites",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

@ -6,7 +6,7 @@ describe('wappalyzer', function(){
var wappalyzer = require("../index"); var wappalyzer = require("../index");
var expect = ['AngularJS','Font Awesome','Google Font API','jQuery','Twitter Bootstrap']; var expect = ['AngularJS','Font Awesome','Google Font API','Twitter Bootstrap','jQuery'];
var options={ var options={
url : "http://codelanka.github.io/Presentation-Engines", url : "http://codelanka.github.io/Presentation-Engines",

Loading…
Cancel
Save