Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency version; Ignore pdf link to avoid crash #380

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const reduce = require('lodash/reduce');
const pick = require('lodash/pick');
const isEmpty = require('lodash/isEmpty');
const uniq = require('lodash/uniq');
const devices = require('puppeteer/DeviceDescriptors');
const devices = require('puppeteer').devices;
const {
resolveUrl,
debugConsole,
Expand Down Expand Up @@ -199,7 +199,8 @@ class Crawler {
*/
_handlePageEvents() {
this._page.on('pageerror', text => void debugConsole(text));
this._page.on('console', msg => void debugConsole(`${msg.type()} ${msg.text()} at ${this._options.url}`));
//this._page.on('console', msg => void debugConsole(`${msg.type()} ${msg.text()} at ${this._options.url}`));
//this._page.on('console', msg => console.log(`${msg.type()} ${msg.text()} at ${this._options.url}`));
this._page.on('dialog', dialog => void this._handleDialog(dialog));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/hccrawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const rp = require('request-promise');
// @ts-ignore
const robotsParser = require('robots-parser');
const Puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const devices = require('puppeteer').devices;
const {
delay,
generateKey,
Expand Down
3 changes: 3 additions & 0 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const crypto = require('crypto');
const pick = require('lodash/pick');
const trim = require('lodash/trim');
const startsWith = require('lodash/startsWith');
const endsWith = require('lodash/endsWith');
const some = require('lodash/some');
const includes = require('lodash/includes');
const isPlainObject = require('lodash/isPlainObject');
Expand Down Expand Up @@ -73,6 +74,8 @@ class Helper {
url = trim(url);
if (!url) return null;
if (startsWith(url, '#')) return null;
if (endsWith(url, '.pdf')) return null;

const { protocol } = parse(url);
if (includes(['http:', 'https:'], protocol)) {
return url.split('#')[0];
Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,34 @@
},
"homepage": "https://github.com/yujiosaka/headless-chrome-crawler#readme",
"dependencies": {
"debug": "3.1.0",
"jquery": "3.5.1",
"lodash": "4.17.20",
"puppeteer": "1.20.0",
"debug": "4.3.2",
"jquery": "3.6.0",
"lodash": "4.17.21",
"puppeteer": "10.1.0",
"request": "2.88.2",
"request-promise": "4.2.6",
"robots-parser": "1.0.2"
"robots-parser": "2.3.0"
},
"peerDependencies": {
"redis": "2.8.0"
"redis": "3.1.2"
},
"devDependencies": {
"@commitlint/cli": "7.0.0",
"@commitlint/config-conventional": "7.0.0",
"@types/debug": "0.0.30",
"@types/lodash": "4.14.162",
"@types/node": "10.3.4",
"@types/puppeteer": "1.20.0",
"@types/request-promise": "4.1.46",
"eslint": "5.0.1",
"eslint-config-airbnb": "17.0.0",
"eslint-plugin-import": "2.13.0",
"@commitlint/cli": "12.1.4",
"@commitlint/config-conventional": "12.1.4",
"@types/debug": "4.1.6",
"@types/lodash": "4.14.171",
"@types/node": "14.17.3",
"@types/puppeteer": "5.4.4",
"@types/request-promise": "4.1.48",
"eslint": "7.31.0",
"eslint-config-airbnb": "18.2.1",
"eslint-plugin-import": "2.23.4",
"greenkeeper-lockfile": "1.15.1",
"husky": "0.14.3",
"jest": "23.1.0",
"mime": "2.3.0",
"redis": "2.8.0",
"typescript": "2.7.2"
"husky": "7.0.1",
"jest": "27.0.6",
"mime": "2.5.2",
"redis": "3.1.2",
"typescript": "4.3.5"
},
"keywords": [
"headless",
Expand Down