Giter Site home page Giter Site logo

Comments (6)

miguelantoniosantos avatar miguelantoniosantos commented on September 7, 2024 2

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.

miguelantoniosantos avatar miguelantoniosantos commented on September 7, 2024 1

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.

miguelcarreiro avatar miguelcarreiro commented on September 7, 2024

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.

JorgeMiguelGomes avatar JorgeMiguelGomes commented on September 7, 2024

@miguelantoniosantos & @miguelcarreiro how long will it take to implement this? Real expectations, please

from bot.

JorgeMiguelGomes avatar JorgeMiguelGomes commented on September 7, 2024

I predict having the scrapper done at the end of Friday (02/09/2020 23:59)

Sounds great!

from bot.

miguelantoniosantos avatar miguelantoniosantos commented on September 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.