@valexe-technologies/lookup.services
Version:
Business Services for Lookup
61 lines • 2.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GoDaddyDomainRegistrar = void 0;
const _1 = require(".");
class GoDaddyDomainRegistrar extends _1.BaseDomainRegistrar {
constructor() {
super(...arguments);
this.properties = {
name: 'GoDaddy',
baseUrl: 'https://in.godaddy.com',
currencyCodes: [
"INR",
"USD"
],
features: [
'Basic DNS'
]
};
}
async getDomainPrice(browser, domainNameWithTLD, currency) {
const selector = 'div:nth-child(1) > div > div > div.text-sm-center.mt-1 > span:nth-child(1) > div > span.text-nowrap > span.main-price';
let page = await browser.newPage();
let url = `${this.properties.baseUrl}/domainsearch/find?checkAvail=1&domainToCheck=${domainNameWithTLD}`;
await this.setupUserAgent(page);
await page.goto(this.properties.baseUrl, {
waitUntil: 'networkidle2'
});
await this.changeCurrency(page, currency);
await page.goto(url, {
waitUntil: 'networkidle2'
});
let innerHtml = await this.waitForSelectorAndGetInnerHtml(page, selector);
await page.close();
if (null == innerHtml) {
console.warn(`Failed to get Element for ${this.properties.name} Price`);
return null;
}
return {
url: url,
price: this.extractPrice(innerHtml)
};
}
async changeCurrency(page, currency) {
let innerHtml = await page.$eval('a > #currentCurrency', (el) => el.innerHTML);
if (null == innerHtml) {
return;
}
innerHtml = innerHtml.trim().toUpperCase();
currency = currency.toUpperCase();
if (innerHtml.includes(currency)) {
return;
}
await page.evaluate((currency) => {
document
.querySelector(`button[data-currencyid='${currency}']`)
.click();
}, currency);
}
}
exports.GoDaddyDomainRegistrar = GoDaddyDomainRegistrar;
//# sourceMappingURL=goDaddyDomainRegistrar.js.map