Skip to content

Commit

Permalink
feat(*): add custom url
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoist Bouteiller committed May 11, 2022
1 parent 92817b3 commit 5bd9e46
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 32 deletions.
5 changes: 1 addition & 4 deletions src/modules/duckduckgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ class DuckduckgoScraper extends Scraper {

async load_start_page() {
debug('load_start_page');
let startUrl = 'https://duckduckgo.com/';

this.last_response = await this.page.goto(startUrl);
this.last_response = await this.page.goto(this.startUrl);
await this.page.waitForSelector('input[name="q"]', { timeout: this.STANDARD_TIMEOUT });

return true;
}

Expand Down
22 changes: 2 additions & 20 deletions src/modules/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,8 @@ class GoogleScraper extends Scraper {
}

async load_start_page() {
let startUrl = 'https://www.google.com';

if (this.config.google_settings) {
startUrl = `https://www.${this.config.google_settings.google_domain}/search?q=`;
if (this.config.google_settings.google_domain) {
startUrl = `https://www.${this.config.google_settings.google_domain}/search?`;
} else {
startUrl = `https://www.google.com/search?`;
}

for (var key in this.config.google_settings) {
if (key !== 'google_domain') {
startUrl += `${key}=${this.config.google_settings[key]}&`
}
}
}

this.logger.info('Using startUrl: ' + startUrl);

this.last_response = await this.page.goto(startUrl);
this.logger.info('Using startUrl: ' + this.startUrl);
this.last_response = await this.page.goto(this.startUrl);

await this.page.waitForSelector('input[name="q"]', { timeout: this.STANDARD_TIMEOUT });

Expand Down
5 changes: 1 addition & 4 deletions src/modules/infospace.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ class InfospaceScraper extends Scraper {
}

async load_start_page() {

let startUrl = this.build_start_url('http://search.infospace.com/search/web?') || 'http://infospace.com/index.html';

try {
this.last_response = await this.page.goto(startUrl);
this.last_response = await this.page.goto(this.this.startUrl);
await this.page.waitForSelector('input[name="q"]', { timeout: 5000 });
} catch (e) {
return false;
Expand Down
7 changes: 3 additions & 4 deletions src/modules/yandex.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ class YandexScraper extends Scraper {
}

async load_start_page() {
let startUrl = 'https://yandex.com';

this.logger.info('Using startUrl: ' + this.startUrl);

this.logger.info('Using startUrl: ' + startUrl);

this.last_response = await this.page.goto(startUrl);
this.last_response = await this.page.goto(this.startUrl);

await this.page.waitForSelector('input[name="text"]', { timeout: this.STANDARD_TIMEOUT });

Expand Down

0 comments on commit 5bd9e46

Please sign in to comment.