Socket
Socket
Sign inDemoInstall

@qualweb/crawler

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qualweb/crawler - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

21

dist/index.js

@@ -6,9 +6,15 @@ 'use strict';

const simplecrawler_1 = __importDefault(require("simplecrawler"));
const log_update_1 = __importDefault(require("log-update"));
const iohook_1 = __importDefault(require("iohook"));
class Crawl {
constructor(domain) {
this.frames = ['-', '\\', '|', '/'];
this.i = 0;
this.urls = new Array();
this.crawler = new simplecrawler_1.default(domain);
this.crawledURLS = 0;
}
async start(options) {
return new Promise(resolve => {
console.log('Starting crawler... Press CTRL+X to stop the crawling process at any time');
if (options) {

@@ -19,2 +25,6 @@ this.crawler.maxConcurrency = 100;

}
let interval = setInterval(() => {
const frame = this.frames[this.i = ++this.i % this.frames.length];
log_update_1.default('Crawled ' + this.crawledURLS + ' pages ' + `${frame}`);
}, 100);
this.crawler.on('fetchcomplete', (item) => {

@@ -25,8 +35,19 @@ if (item && item['stateData'] && item['stateData']['contentType'] &&

this.urls.push(item.url);
const frame = this.frames[this.i = ++this.i % this.frames.length];
log_update_1.default('Crawled ' + this.crawledURLS++ + ' pages ' + `${frame}`);
}
});
this.crawler.on('complete', () => {
clearInterval(interval);
this.stop();
resolve();
console.log('\nCrawler done!');
});
iohook_1.default.on('keydown', event => {
if (event && event.ctrlKey && event.keycode === 45) {
this.crawler.emit('complete');
iohook_1.default.stop();
}
});
iohook_1.default.start();
this.crawler.start();

@@ -33,0 +54,0 @@ });

4

package.json
{
"name": "@qualweb/crawler",
"version": "0.1.1",
"version": "0.2.0",
"description": "Webpage crawler for qualweb",

@@ -31,2 +31,4 @@ "main": "dist/index.js",

"dependencies": {
"iohook": "^0.6.5",
"log-update": "^4.0.0",
"simplecrawler": "^1.1.8"

@@ -33,0 +35,0 @@ },

'use strict';
import Crawler from 'simplecrawler';
import logUpdate from 'log-update';
import ioHook from 'iohook';

@@ -9,2 +11,5 @@ class Crawl {

private crawler: Crawler;
private crawledURLS: number;
private frames = ['-', '\\', '|', '/'];
private i = 0;

@@ -14,2 +19,3 @@ constructor(domain: string) {

this.crawler = new Crawler(domain);
this.crawledURLS = 0;
}

@@ -19,2 +25,3 @@

return new Promise(resolve => {
console.log('Starting crawler... Press CTRL+X to stop the crawling process at any time');
if (options) {

@@ -26,2 +33,7 @@ this.crawler.maxConcurrency = 100;

let interval = setInterval(() => {
const frame = this.frames[this.i = ++this.i % this.frames.length];
logUpdate('Crawled ' + this.crawledURLS + ' pages ' + `${frame}` );
}, 100);
this.crawler.on('fetchcomplete', (item: any) => {

@@ -32,10 +44,23 @@ if (item && item['stateData'] && item['stateData']['contentType'] &&

this.urls.push(item.url);
const frame = this.frames[this.i = ++this.i % this.frames.length];
logUpdate('Crawled ' + this.crawledURLS++ + ' pages ' + `${frame}`);
}
});
this.crawler.on('complete', () => {
clearInterval(interval);
this.stop();
resolve();
console.log('\nCrawler done!');
});
ioHook.on('keydown', event => {
if (event && event.ctrlKey && event.keycode === 45) {
this.crawler.emit('complete');
ioHook.stop();
}
});
ioHook.start();
this.crawler.start();

@@ -42,0 +67,0 @@ });

@@ -7,3 +7,3 @@ const Crawl = require('../dist/index');

this.timeout(10 * 100000);
const crawler = new Crawl('https://lodash.com');
const crawler = new Crawl('https://ciencias.ulisboa.pt');
await crawler.start();

@@ -10,0 +10,0 @@ const urls = crawler.getResults();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc