You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import 'dotenv/config'
|
|
|
|
import puppeteer from 'puppeteer'
|
|
|
|
|
|
|
|
const NIX_OPS = {
|
|
|
|
executablePath: process.env.NIX_CHROMIUM_PATH,
|
|
|
|
}
|
|
|
|
const opts = process.env.ON_NIX ? NIX_OPS : {}
|
|
|
|
|
|
|
|
const HOUR = 21
|
|
|
|
|
|
|
|
const fetchILMeteo = async () => {
|
|
|
|
const browser = await puppeteer.launch(opts)
|
|
|
|
const page = await browser.newPage()
|
|
|
|
|
|
|
|
await page.goto('https://www.ilmeteo.it/meteo/Pisa')
|
|
|
|
|
|
|
|
const weatherTable = await page.locator('.weather_table').waitHandle()
|
|
|
|
const row = await weatherTable.$(`.forecast_1h[data-hour="${HOUR}"]`)
|
|
|
|
const temp = await row.$('[data-value="temperatura"]')
|
|
|
|
console.log(await temp?.evaluate(el => el.textContent))
|
|
|
|
|
|
|
|
await browser.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchILMeteo()
|