From a0e63aa4b00f5d0c842f1bb2810770329b88cba9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 26 Apr 2019 15:13:51 +0200 Subject: [PATCH] Use bing_setting.bing_domain if defined for startUrl --- src/modules/bing.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/modules/bing.js b/src/modules/bing.js index d536761..a888c8f 100644 --- a/src/modules/bing.js +++ b/src/modules/bing.js @@ -47,6 +47,21 @@ class BingScraper extends Scraper { async load_start_page() { let startUrl = this.build_start_url('https://www.bing.com/search?') || 'https://www.bing.com/'; + if (this.config.bing_settings) { + startUrl = `https://www.${this.config.bing_settings.bing_domain}/search?`; + if (this.config.bing_settings.bing_domain) { + startUrl = `https://www.${this.config.bing_settings.bing_domain}/search?`; + } else { + startUrl = `https://www.bing.com/search?`; + } + + for (var key in this.config.bing_settings) { + if (key !== 'bing_domain') { + startUrl += `${key}=${this.config.bing_settings[key]}&` + } + } + } + try { await this.page.goto(startUrl); await this.page.waitForSelector('input[name="q"]', { timeout: this.STANDARD_TIMEOUT }); @@ -171,4 +186,4 @@ class BingNewsScraper extends Scraper { module.exports = { BingNewsScraper: BingNewsScraper, BingScraper: BingScraper, -}; \ No newline at end of file +};