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 MY_PACKAGE_SELECTOR_ID =
|
||||
'table[style="margin-top:-10px;"] tr:first-child+tr';
|
||||
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 KEYS = ['live', 'flexibytes'];
|
||||
|
||||
var browser;
|
||||
|
||||
async function getUsage() {
|
||||
|
@ -24,24 +25,28 @@ async function getUsage() {
|
|||
};
|
||||
|
||||
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.waitFor(3000),
|
||||
(dataUsage = await page.evaluate(sel => {
|
||||
let elements = document.getElementsByClassName(sel);
|
||||
// Wait for the page to switch
|
||||
await page.waitForFunction(
|
||||
'document.querySelector(".dtl-header-text").innerText === "My Package"'
|
||||
);
|
||||
|
||||
if (!elements || elements.length < 4) {
|
||||
return '0.00 0.00';
|
||||
}
|
||||
let usage = {
|
||||
live: elements[3].innerText,
|
||||
aggregate: '0.00 GB (Quota 800.00 GB)',
|
||||
};
|
||||
if (elements.length >= 6) {
|
||||
usage['flexibytes'] = elements[5].innerText;
|
||||
}
|
||||
return usage;
|
||||
}, DATA_SELECTOR));
|
||||
dataUsage = await page.evaluate(sel => {
|
||||
let elements = document.getElementsByClassName(sel);
|
||||
|
||||
if (!elements || elements.length < 4) {
|
||||
return '0.00 0.00';
|
||||
}
|
||||
let usage = {
|
||||
live: elements[3].innerText,
|
||||
aggregate: '0.00 GB (Quota 800.00 GB)',
|
||||
};
|
||||
if (elements.length >= 6) {
|
||||
usage['flexibytes'] = elements[5].innerText;
|
||||
}
|
||||
return usage;
|
||||
}, DATA_SELECTOR);
|
||||
|
||||
// ['0.00 GB (Quota 800.00 GB)', '102.58 GB(Quota 100.00 GB)']
|
||||
KEYS.map(key => {
|
||||
|
|
|
@ -235,10 +235,10 @@
|
|||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz",
|
||||
"integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4="
|
||||
},
|
||||
"puppeteer": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.5.0.tgz",
|
||||
"integrity": "sha512-eELwFtFxL+uhmg4jPZOZXzSrPEYy4CaYQNbcchBbfxY+KjMpnv6XGf/aYWaQG49OTpfi2/DMziXtDM8XuJgoUA==",
|
||||
"puppeteer-core": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-1.7.0.tgz",
|
||||
"integrity": "sha512-SpUOJL8gTPEuABGcZxKM3jg5s0rIwmRC6P9Jw/JTG3XFCVtUcYQru4Uwlz7jAXe6JEeeLOm6hApgGCmRyALiig==",
|
||||
"requires": {
|
||||
"debug": "^3.1.0",
|
||||
"extract-zip": "^1.6.6",
|
||||
|
|
10
package.json
10
package.json
|
@ -1,16 +1,12 @@
|
|||
{
|
||||
"name": "prometheus-act-exporter",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"description": "Exports ACT Fibernet data usage as prometheus metrics",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
"actcorp",
|
||||
"balance",
|
||||
"flexibyte"
|
||||
],
|
||||
"keywords": ["actcorp", "balance", "flexibyte"],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@git.captnemo.in/nemo/prometheus-act-exporter.git"
|
||||
|
@ -23,6 +19,6 @@
|
|||
"dependencies": {
|
||||
"containerized": "^1.0.2",
|
||||
"prom-client": "^11.1.0",
|
||||
"puppeteer": "^1.5.0"
|
||||
"puppeteer-core": "^1.7.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue