initial commit

main
Fran314 4 weeks ago
commit 7971aafe10

@ -0,0 +1,2 @@
NIX_CHROMIUM_PATH=<PATH/TO/CHROMIUM/INSIDE/NIX/STORE>
ON_NIX="true"

7
.gitignore vendored

@ -0,0 +1,7 @@
# Node dependencies
node_modules
# Local env files
.env
.env.*
!.env.example

@ -0,0 +1,10 @@
{
"printWidth": 80,
"singleQuote": true,
"quoteProps": "consistent",
"tabWidth": 4,
"semi": false,
"arrowParens": "avoid",
"proseWrap": "always"
}

@ -0,0 +1,39 @@
# Weather Web-Scraper
An utility to scrape italian weather websites to collect and compare weather
information
## Usage
> ![CAUTION]
> The following utility is in EARLY developement. Many promises made in this
> readme might not actually be true. Hopefully one day we'll be out of beta ~and
> be releasing on time~
The scraper collects data and arranges in the following scheme
| Object field | Data Type | Unit of measurement | Meaning |
| ------------ | --------- | ------------------- | ------- |
| | | | |
> ![WARNING]
> The script is configured to run on Nix, and because of this is more
> complicated than it needs to be. You can remove unnecessary stuff if you're
> not running this on nix
### Sources
These are the sources that are currently implemented or will be implemented
eventually, together with the current level of implementation
```
✅ = implemented
🚧 = partially implemented
⛔️ = Not implemented
```
| Source | Status | Comments |
| ---------------------------------------------------- | ------ | -------- |
| [iLMeteo](https://www.ilmeteo.it) | ⛔️ | |
| [3BMeteo](https://www.3bmeteo.com/) | ⛔️ | |
| [Meteo Aeronautica Militare](http://www.meteoam.it/) | ⛔️ | |

@ -0,0 +1,25 @@
require('dotenv').config()
const puppeteer = require('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()

1113
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,6 @@
{
"dependencies": {
"dotenv": "^16.4.5",
"puppeteer": "^23.6.0"
}
}
Loading…
Cancel
Save