Comments (6)
After a direct chat with @miguelcarreiro, we decided @miguelcarreiro will be making the twitter integration, I (@miguelantoniosantos) will be making the scrapper.
The scrapper will be an module with the following format:
class MeteoAlarm {
async fetch() {
}
async fetchSingle(countryShortcode) {
}
}
module.exports = new MeteoAlarm();
They async function fetch will return an object with the keys being a country short code and the value being an array.
This array will have multiple (0+) objects, representing an alert, with the following format:
{
type: '',
status: '',
start: '',
end: '',
severity: '',
region: '',
}
I predict having the scrapper done at the end of Friday (02/09/2020 23:59)
from bot.
The way I found for parsing is:
We get all the countries with warnings with:
let warnings = document.querySelectorAll('.warn.awt');
let country_url = warning[0].parentElement.parentElement.href;
Go through each one that is unique.
Then we have two options, processing the tooltip or opening the region warning and parsing the region page.
I suggest going to the region page as it seems more consistant.
let warnings = document.querySelectorAll('.warn2.awt2');
let text = warnings[0].parentElement.parentElement.getAttribute('onclick');
let regex = /transfer_to_area\('([^']+)'\)/m;
let region_url= text.match(regex)[1]);
And in the region page we parse the region name warnings and all the data needed.
@miguelcarreiro seems good?
from bot.
The way I found for parsing is:
We get all the countries with warnings with:
let warnings = document.querySelectorAll('.warn.awt'); let country_url = warning[0].parentElement.parentElement.href;Go through each one that is unique.
Then we have two options, processing the tooltip or opening the region warning and parsing the region page.
I suggest going to the region page as it seems more consistant.let warnings = document.querySelectorAll('.warn2.awt2'); let text = warnings[0].parentElement.parentElement.getAttribute('onclick'); let regex = /transfer_to_area\('([^']+)'\)/m; let region_url= text.match(regex)[1]);And in the region page we parse the region name warnings and all the data needed.
@miguelcarreiro seems good?
@miguelantoniosantos Looks good, although Meteoalarm also has a RSS feed with the list of countries, and then each country have it's own RSS feed with all regions.
I watched RSS feeds, and it has some problems, for example, the only way to see if a warning was issued is by looking at the image URL, whereas in source code we can check 'warn2' class attribute), so I think that scraping would be a better solution.
from bot.
@miguelantoniosantos & @miguelcarreiro how long will it take to implement this? Real expectations, please
from bot.
I predict having the scrapper done at the end of Friday (02/09/2020 23:59)
Sounds great!
from bot.
Created a gist with an example output of MeteoAlarm.fetch()
Here is an example use of the scrapper:
const MeteoAlarm = require('./api/MeteoAlarm');
async function get() {
const portuguese_data = await MeteoAlarm.fetchSingle('PT');
const all_data = await MeteoAlarm.fetch();
}
get();
from bot.
Related Issues (20)
- [Feat] Monitor Google Sheet to notify Discord and Tweet HOT 3
- [FEAT] Do a checksum on DGS COVID-19 reports
- splitMessageString enters an infinite loop with too long messages
- [Feat] Remind DGS on Twitter of missing daily reports on the website
- [Chore] Remove VSCode Theme Settings
- [Docs] Pull Request Template HOT 1
- [FEAT] [COVID19PT] Create command to update, via Discord, the daily numbers HOT 3
- [FEAT] Agitação Marítima em Beja HOT 3
- [feat] add service for bot to publish to Facebook
- [feat] Mirror posting of @Portugal_DRE HOT 2
- License disclaimer discrepancy
- Switch to new MeteoAlarm feeds HOT 1
- [FEAT] Weekly Variation
- [FEAT] Integrate daily extremes report and send it to social networks HOT 4
- [FEAT] Publish sensed earthquakes to social networks HOT 2
- [FEAT] Update discord.js version
- [BUG] Personal greetings not working
- [FEAT] Implement Alerts on Mastodon HOT 1
- [BUG] Remove yellow weather warming from IPMA to be sent to twitter due to restrictions of api HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bot.