Add cookie detection to NPM driver

main
Elbert Alias 7 years ago
parent 65dfc75e8c
commit 4d307ef90b

@ -127,12 +127,14 @@ class Driver {
const html = this.getHtml(browser); const html = this.getHtml(browser);
const scripts = this.getScripts(browser); const scripts = this.getScripts(browser);
const js = this.getJs(browser); const js = this.getJs(browser);
const cookies = this.getCookies(browser);
this.wappalyzer.analyze(pageUrl, { this.wappalyzer.analyze(pageUrl, {
headers, headers,
html, html,
scripts, scripts,
js js,
cookies,
}) })
.then(() => { .then(() => {
const links = Array.prototype.reduce.call( const links = Array.prototype.reduce.call(
@ -267,6 +269,21 @@ class Driver {
return js; return js;
} }
getCookies(browser) {
const cookies = [];
if ( browser.cookies ) {
browser.cookies.forEach(cookie => cookies.push({
name: cookie.key,
value: cookie.value,
domain: cookie.domain,
path: cookie.path,
}));
}
return cookies;
}
crawl(pageUrl, index, depth = 1) { crawl(pageUrl, index, depth = 1) {
pageUrl.canonical = pageUrl.protocol + '//' + pageUrl.host + pageUrl.pathname; pageUrl.canonical = pageUrl.protocol + '//' + pageUrl.host + pageUrl.pathname;

Loading…
Cancel
Save