-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const axios = require('axios');
const puppeteer = require('puppeteer');
const params = new URLSearchParams();
const url = 'http://app.sct.gob.mx/sibuac_internet/ControllerUI?action=cmdSolRutas';
params.append('edoOrigen', '22');
params.append('edoDestino', '25');
params.append('ciudadOrigen', '22110');
params.append('ciudadDestino', '25270');
params.append('vehiculos', '2');
params.append('red', 'simplificada');
params.append('tipo', '1');
(async () => {
const {data} = await axios.post(url, params, {responseType: 'arraybuffer'});
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent(data.toString('latin1'));
await page.evaluate(() => {
const table = document.querySelectorAll('#tContenido tr');
table.deleteRow(0);
table.deleteRow(table.rows.length - 1);
table.deleteRow(table.rows.length - 1);
table.deleteRow(table.rows.length - 1);
table.deleteRow(table.rows.length - 1);
});
const logo = await page.$('table#tContenido');
await logo.screenshot({
path: 'example.png'
});
await browser.close();
})();