Skip to content

Commit

Permalink
fix: fix command line mode
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Mar 13, 2021
1 parent 9fcf266 commit dad7d54
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scrap-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ module.exports = async (baseUrl, options = {}) => {
const protocol = url.parse(baseUrl).protocol;

const log = (msg) => {
if (DEBUG) console.log(`${options.socket.id} ${msg}`);
const socketId = options.socket ? `options.socket.id ` : '';
if (DEBUG) console.log(`${socketId}${msg}`);
socketSend(options.socket, 'status', msg);
};
options.log = log;
Expand Down Expand Up @@ -326,7 +327,7 @@ module.exports = async (baseUrl, options = {}) => {
page.on('requestfailed', request => {
if (request.notHTTPS) {
console.error(
`${color.red}mixed content: ${request.url()}${color.reset}`);
`${color.red}${crawler._options.url}: mixed content: ${request.url()}${color.reset}`);
} else {
const isStatic = ['image', 'script', 'stylesheet'].includes(request.resourceType());
if (!isStatic) console.log('Request failed: ', request.url() + ' ' + request.failure().errorText);
Expand Down Expand Up @@ -530,6 +531,7 @@ module.exports = async (baseUrl, options = {}) => {
`${color.red}Failed: ${decodeURI(error.options.url)}${color.reset}`);
});
crawler.on('requestdisallowed', options => {
log(`Disallowed in robots.txt: ${decodeURI(options.url)}`, options.socket);
console.error(`${color.yellow}Disallowed in robots.txt: ${decodeURI(
options.url)}${color.reset}`);
});
Expand Down

0 comments on commit dad7d54

Please sign in to comment.