Upgrade puppeteer (1.7.0)
- Switches to the -core package which does not force a download on npm install
This commit is contained in:
parent
18409460eb
commit
569f02ad38
41
index.js
41
index.js
|
@ -1,12 +1,13 @@
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer-core');
|
||||||
const containerized = require('containerized');
|
const containerized = require('containerized');
|
||||||
|
|
||||||
const MY_PACKAGE_SELECTOR_ID =
|
const MY_PACKAGE_SELECTOR_ID =
|
||||||
'table[style="margin-top:-10px;"] tr:first-child+tr';
|
'table[style="margin-top:-10px;"] tr:first-child+tr';
|
||||||
const DATA_SELECTOR = 'packagecol3';
|
const DATA_SELECTOR = 'packagecol3';
|
||||||
|
const MY_ACCOUNT_URL = 'https://selfcare.actcorp.in/group/blr/myaccount';
|
||||||
const DATA_USAGE_REGEX = /\d+\.\d{0,2}/g;
|
const DATA_USAGE_REGEX = /\d+\.\d{0,2}/g;
|
||||||
const KEYS = ['live', 'flexibytes'];
|
const KEYS = ['live', 'flexibytes'];
|
||||||
|
|
||||||
var browser;
|
var browser;
|
||||||
|
|
||||||
async function getUsage() {
|
async function getUsage() {
|
||||||
|
@ -24,24 +25,28 @@ async function getUsage() {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await page.goto('http://portal.actcorp.in/group/blr/myaccount');
|
await page.goto(MY_ACCOUNT_URL);
|
||||||
await page.click(MY_PACKAGE_SELECTOR_ID);
|
await page.click(MY_PACKAGE_SELECTOR_ID);
|
||||||
await page.waitFor(3000),
|
// Wait for the page to switch
|
||||||
(dataUsage = await page.evaluate(sel => {
|
await page.waitForFunction(
|
||||||
let elements = document.getElementsByClassName(sel);
|
'document.querySelector(".dtl-header-text").innerText === "My Package"'
|
||||||
|
);
|
||||||
|
|
||||||
if (!elements || elements.length < 4) {
|
dataUsage = await page.evaluate(sel => {
|
||||||
return '0.00 0.00';
|
let elements = document.getElementsByClassName(sel);
|
||||||
}
|
|
||||||
let usage = {
|
if (!elements || elements.length < 4) {
|
||||||
live: elements[3].innerText,
|
return '0.00 0.00';
|
||||||
aggregate: '0.00 GB (Quota 800.00 GB)',
|
}
|
||||||
};
|
let usage = {
|
||||||
if (elements.length >= 6) {
|
live: elements[3].innerText,
|
||||||
usage['flexibytes'] = elements[5].innerText;
|
aggregate: '0.00 GB (Quota 800.00 GB)',
|
||||||
}
|
};
|
||||||
return usage;
|
if (elements.length >= 6) {
|
||||||
}, DATA_SELECTOR));
|
usage['flexibytes'] = elements[5].innerText;
|
||||||
|
}
|
||||||
|
return usage;
|
||||||
|
}, DATA_SELECTOR);
|
||||||
|
|
||||||
// ['0.00 GB (Quota 800.00 GB)', '102.58 GB(Quota 100.00 GB)']
|
// ['0.00 GB (Quota 800.00 GB)', '102.58 GB(Quota 100.00 GB)']
|
||||||
KEYS.map(key => {
|
KEYS.map(key => {
|
||||||
|
|
|
@ -235,10 +235,10 @@
|
||||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz",
|
||||||
"integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4="
|
"integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4="
|
||||||
},
|
},
|
||||||
"puppeteer": {
|
"puppeteer-core": {
|
||||||
"version": "1.5.0",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-1.7.0.tgz",
|
||||||
"integrity": "sha512-eELwFtFxL+uhmg4jPZOZXzSrPEYy4CaYQNbcchBbfxY+KjMpnv6XGf/aYWaQG49OTpfi2/DMziXtDM8XuJgoUA==",
|
"integrity": "sha512-SpUOJL8gTPEuABGcZxKM3jg5s0rIwmRC6P9Jw/JTG3XFCVtUcYQru4Uwlz7jAXe6JEeeLOm6hApgGCmRyALiig==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
"extract-zip": "^1.6.6",
|
"extract-zip": "^1.6.6",
|
||||||
|
|
10
package.json
10
package.json
|
@ -1,16 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "prometheus-act-exporter",
|
"name": "prometheus-act-exporter",
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"description": "Exports ACT Fibernet data usage as prometheus metrics",
|
"description": "Exports ACT Fibernet data usage as prometheus metrics",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": ["actcorp", "balance", "flexibyte"],
|
||||||
"actcorp",
|
|
||||||
"balance",
|
|
||||||
"flexibyte"
|
|
||||||
],
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@git.captnemo.in/nemo/prometheus-act-exporter.git"
|
"url": "git+ssh://git@git.captnemo.in/nemo/prometheus-act-exporter.git"
|
||||||
|
@ -23,6 +19,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"containerized": "^1.0.2",
|
"containerized": "^1.0.2",
|
||||||
"prom-client": "^11.1.0",
|
"prom-client": "^11.1.0",
|
||||||
"puppeteer": "^1.5.0"
|
"puppeteer-core": "^1.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue