Upload files to "/"
This commit is contained in:
parent
2ebe533e82
commit
1b1241c306
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "start-fermate",
|
"name": "start-fermate-api",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"main": "script.js",
|
"main": "script.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node server.js"
|
"start": "node server.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "IlDani - Curry141",
|
||||||
"license": "ISC",
|
"license": "MIT",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.10.0",
|
"axios": "^1.10.0",
|
||||||
|
|
14
server.js
14
server.js
|
@ -15,12 +15,16 @@ app.get('/', async (req, res) => {
|
||||||
const response = await axios.get(url);
|
const response = await axios.get(url);
|
||||||
const $ = cheerio.load(response.data);
|
const $ = cheerio.load(response.data);
|
||||||
const results = [];
|
const results = [];
|
||||||
|
const fermata = $('h2.fw-bold.text-primary.title').text().trim();
|
||||||
|
results.push({
|
||||||
|
fermata
|
||||||
|
});
|
||||||
$('.container.mb-50 .bus-card').each((i, el) => {
|
$('.container.mb-50 .bus-card').each((i, el) => {
|
||||||
const element = $(el);
|
const element = $(el);
|
||||||
|
|
||||||
const isSoppressa = element.find('.bus-status.sopp').length > 0;
|
const isSoppressa = element.find('.bus-status.sopp').length > 0;
|
||||||
|
|
||||||
const headerSpan = element.find('.bus-header span').first();
|
const headerSpan = element.find('.bus-header span').first();
|
||||||
|
const orario = element.find('.bus-times span').first().text().trim();
|
||||||
|
var stato = element.find('.bus-status').text().trim();
|
||||||
var linea = headerSpan.contents().filter((i, el) => el.type === 'text').text().trim();
|
var linea = headerSpan.contents().filter((i, el) => el.type === 'text').text().trim();
|
||||||
const destinazione = element.find('.bus-destination').text().trim();
|
const destinazione = element.find('.bus-destination').text().trim();
|
||||||
var mezzo = element.find('.det a').attr('data-vehicle') || '';
|
var mezzo = element.find('.det a').attr('data-vehicle') || '';
|
||||||
|
@ -29,6 +33,10 @@ app.get('/', async (req, res) => {
|
||||||
mezzo = 3 + mezzo;
|
mezzo = 3 + mezzo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(stato == "Non disp"){
|
||||||
|
stato = "Non disponibile";
|
||||||
|
}
|
||||||
|
|
||||||
if(mezzo == ""){
|
if(mezzo == ""){
|
||||||
mezzo = "Non disponibile";
|
mezzo = "Non disponibile";
|
||||||
}
|
}
|
||||||
|
@ -49,6 +57,8 @@ app.get('/', async (req, res) => {
|
||||||
results.push({
|
results.push({
|
||||||
linea,
|
linea,
|
||||||
destinazione,
|
destinazione,
|
||||||
|
orario,
|
||||||
|
stato,
|
||||||
mezzo,
|
mezzo,
|
||||||
soppressa: isSoppressa
|
soppressa: isSoppressa
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue