-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcc0078
commit 4e98aa1
Showing
21 changed files
with
3,154 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
*.py[cod] | ||
tmp.py | ||
.idea | ||
*.db | ||
tmp | ||
node_modules/ | ||
.* | ||
!/.gitignore | ||
package-lock.json |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/* | ||
HTCAP - 1.2 | ||
http://htcap.org | ||
Author: [email protected] | ||
This program is free software; you can redistribute it and/or modify it under | ||
the terms of the GNU General Public License as published by the Free Software | ||
Foundation; either version 2 of the License, or (at your option) any later | ||
version. | ||
*/ | ||
|
||
|
||
"use strict"; | ||
|
||
const htcap = require("./htcap"); | ||
const utils = require('./utils'); | ||
const process = require('process'); | ||
|
||
|
||
var sleep = function(n){ | ||
return new Promise(resolve => { | ||
setTimeout(resolve, n); | ||
}); | ||
}; | ||
|
||
|
||
|
||
var argv = utils.parseArgs(process.argv, "hVaftUJdICc:MSEp:Tsx:A:r:mHX:PD:R:Oi:u:vy:l", {}); | ||
var options = argv.opts | ||
|
||
var targetUrl = argv.args[0]; | ||
|
||
|
||
|
||
if(!targetUrl){ | ||
utils.usage(); | ||
process.exit(-1); | ||
} | ||
|
||
targetUrl = targetUrl.trim(); | ||
if(targetUrl.length < 4 || targetUrl.substring(0,4).toLowerCase() != "http"){ | ||
targetUrl = "http://" + targetUrl; | ||
} | ||
|
||
|
||
|
||
htcap.launch(targetUrl, options).then( crawler => { | ||
const page = crawler.page(); | ||
var execTO = null; | ||
|
||
console.log("["); | ||
|
||
function exit(){ | ||
clearTimeout(execTO); | ||
crawler.browser().close(); | ||
} | ||
|
||
crawler.on("redirect", async function(e, crawler){ | ||
// console.log(crawler.redirect()); | ||
// console.log(e.params.url); | ||
// utils.printCookies(crawler); | ||
// utils.printRequest({type:'link',method:"GET",url:e.params.url}); | ||
// exit(); | ||
}); | ||
|
||
|
||
crawler.on("domcontentloaded", async function(e, crawler){ | ||
//utils.printCookies(crawler); | ||
await utils.printLinks("html", crawler.page()) | ||
await utils.printForms("html", crawler.page()) | ||
|
||
//await sleep(4000) | ||
}); | ||
|
||
crawler.on("start", function(e, crawler){ | ||
//console.log("--->Start"); | ||
}) | ||
|
||
|
||
crawler.on("newdom", async function(e, crawler){ | ||
//console.log(e.params) | ||
}) | ||
|
||
crawler.on("xhr", async function(e, crawler){ | ||
utils.printRequest(e.params.request) | ||
|
||
//return false | ||
}); | ||
|
||
crawler.on("xhrCompleted", function(e, crawler){ | ||
//console.log("XHR completed") | ||
}); | ||
|
||
|
||
crawler.on("jsonp", function(e, crawler){ | ||
utils.printRequest(e.params.request) | ||
}); | ||
|
||
crawler.on("jsonpCompleted", function(e, crawler){ | ||
|
||
}); | ||
|
||
crawler.on("websocket", function(e, crawler){ | ||
utils.printRequest(e.params.request) | ||
}); | ||
|
||
crawler.on("websocketMessage", function(e, crawler){ | ||
|
||
}); | ||
|
||
crawler.on("websocketSend", function(e, crawler){ | ||
|
||
}); | ||
|
||
crawler.on("formSubmit", function(e, crawler){ | ||
utils.printRequest(e.params.request) | ||
}); | ||
|
||
crawler.on("navigation", function(e, crawler){ | ||
e.params.request.type="link"; | ||
utils.printRequest(e.params.request) | ||
}); | ||
|
||
crawler.on("eventtriggered", function(e, crawler){ | ||
//console.log(e.params) | ||
}); | ||
|
||
crawler.on("triggerevent", function(e, crawler){ | ||
//console.log(e.params) | ||
}); | ||
|
||
crawler.on("earlydetach", function(e, crawler){ | ||
//console.log('["warning","earlydetach of element ' + e.params.node + '],') | ||
//crawler.browser().close(); | ||
}); | ||
|
||
|
||
async function end(){ | ||
if(!crawler.redirect()){ | ||
const el = await crawler.page().$("html"); | ||
const v = await el.getProperty('innerText'); | ||
const hash = await v.jsonValue(); | ||
var json = '["page_hash",' + JSON.stringify(hash) + '],'; | ||
console.log(json); | ||
|
||
if(options.returnHtml){ | ||
json = '["html",' + JSON.stringify(hash) + '],'; | ||
console.log(json); | ||
} | ||
} | ||
|
||
utils.printStatus(crawler); | ||
exit(); | ||
} | ||
|
||
crawler.on("end", end); | ||
|
||
execTO = setTimeout(function(){ // (very dirty solution) | ||
crawler.on("end", function(){}); | ||
crawler.errors().push(["probe_timeout", "maximum execution time reached"]); | ||
end(); | ||
}, options.maxExecTime); | ||
|
||
|
||
crawler.start() | ||
|
||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
try{ | ||
require("puppeteer") | ||
} catch(e) { | ||
console.log("puppeteer") | ||
} |
Oops, something went wrong.