Use bing_setting.bing_domain if defined for startUrl

This commit is contained in:
Thomas 2019-04-26 15:13:51 +02:00 committed by HugoPoi
parent a3ebe357a4
commit a0e63aa4b0

View File

@ -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,
};
};