• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Help with puppeteer ,cheerio and json

Scheduled Pinned Locked Moved Development
9 Posts 2 Posters 611 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    lolo
    last edited by Dec 8, 2020, 8:28 PM

    Yes I’m getting date , but this one is endWork (kraj). When the interruption will end, not to start. I know maybe I should use that.

    1 Reply Last reply Reply Quote 0
    • L Offline
      lolo
      last edited by Dec 9, 2020, 11:47 AM

      I think i managed to sort it out.

      	const $ = cheerio.load(html);
          
      	var water = [];
              var waterList = [];
              var el = $('#cphContent_cphSadrzaj_upVoda table tbody ');
          
      	if (el) {
                     var elementWater = $('#cphContent_cphSadrzaj_upVoda table tbody  span').filter(function () {
                        return $(this).text() === self.place;
                         }).parent().parent();
                   $(elementWater).each(function (jex, edate) {
      
                  const $edate = $(edate);
                  var startDate = $edate.prev().find('tr[class="datum"]>th>div').text().trim();
                  var street = $edate.find('span[id*="Label2"]').text();
                  var streetNmbr = $edate.find('span[id*="Label7"]').text();
                  var startTime = $edate.find('span[id*="Label8"]').text();
                  var endTime = $edate.find('span[id*="Label9"]').text();
                  var endWork = $edate.find('span[id*="Label10"]').text();
      
                  var water = {
                      startDate,
                      street,
                      streetNmbr,
                      startTime,
                      endTime,
                      endWork
                  };
                  
              
                  waterList.push(water);
                  console.log(water);
              });
      
          };
          if (!el) {
              console.log('No new entries!');
          };
          var waterWork = JSON.parse(JSON.stringify(waterList));
          self.sendSocketNotification('ELECTRIC_POWER_DISCONNECTED', waterWork);
      

      Now i can get all data sorted by config.place

       {
        startDate: '09.12.2020',
        street: 'ISTARSKA, Rijeka',
        streetNmbr: '64',
        startTime: '10:00',
        endTime: '14:00',
        endWork: '09.12.20'
      }
      
      
      S 1 Reply Last reply Dec 9, 2020, 12:42 PM Reply Quote 0
      • S Away
        sdetweil @lolo
        last edited by Dec 9, 2020, 12:42 PM

        @lolo cool

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • L Offline
          lolo
          last edited by Dec 14, 2020, 7:01 PM

          This is output of my module. Any suggestion about styling.
          srdoči.PNG
          šmrika.PNG
          brnelići.PNG
          croatian
          brnelići2.PNG

          I know there are more things to make it better but i have to learn it first.

          S 1 Reply Last reply Dec 14, 2020, 9:28 PM Reply Quote 0
          • S Away
            sdetweil @lolo
            last edited by Dec 14, 2020, 9:28 PM

            @lolo i cannot help with look. Totally useless here

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              9/9
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Sam, technical setup by Karsten.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy