forked from extern/se-scraper
some minor changes
This commit is contained in:
parent
e661241f6f
commit
855a874f9e
@ -151,19 +151,19 @@ module.exports = class Scraper {
|
|||||||
this.results[keyword] = {};
|
this.results[keyword] = {};
|
||||||
this.result_rank = 1;
|
this.result_rank = 1;
|
||||||
|
|
||||||
if (this.pluggable && this.pluggable.before_keyword_scraped) {
|
|
||||||
await this.pluggable.before_keyword_scraped({
|
|
||||||
results: this.results,
|
|
||||||
num_keywords: this.num_keywords,
|
|
||||||
num_requests: this.num_requests,
|
|
||||||
keyword: keyword,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.page_num = 1;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if (this.pluggable && this.pluggable.before_keyword_scraped) {
|
||||||
|
await this.pluggable.before_keyword_scraped({
|
||||||
|
results: this.results,
|
||||||
|
num_keywords: this.num_keywords,
|
||||||
|
num_requests: this.num_requests,
|
||||||
|
keyword: keyword,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.page_num = 1;
|
||||||
|
|
||||||
// load scraped page from file if `scrape_from_file` is given
|
// load scraped page from file if `scrape_from_file` is given
|
||||||
if (this.config.scrape_from_file.length <= 0) {
|
if (this.config.scrape_from_file.length <= 0) {
|
||||||
await this.search_keyword(keyword);
|
await this.search_keyword(keyword);
|
||||||
@ -286,23 +286,17 @@ module.exports = class Scraper {
|
|||||||
if (this.config.throw_on_detection === true) {
|
if (this.config.throw_on_detection === true) {
|
||||||
throw( e );
|
throw( e );
|
||||||
} else {
|
} else {
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// some other error, quit scraping process if stuff is broken
|
// some other error, quit scraping process if stuff is broken
|
||||||
if (this.config.is_local === true) {
|
if (this.config.throw_on_detection === true) {
|
||||||
console.error('You have 30 seconds to fix this.');
|
throw( e );
|
||||||
await this.sleep(30000);
|
|
||||||
} else {
|
} else {
|
||||||
if (this.config.throw_on_detection === true) {
|
return;
|
||||||
throw( e );
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user