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 883 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.
    • S Offline
      sdetweil @lolo
      last edited by

      @lolo but u have the date already in the object. Sort them maybe, but cheerio should return the list in order.

      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

        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

          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 Reply Quote 0
          • S Offline
            sdetweil @lolo
            last edited by

            @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

              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 Reply Quote 0
              • S Offline
                sdetweil @lolo
                last edited by

                @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
                • First post
                  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