Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Vorkommen Homepage zählen (Parser oder Blocky)

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Vorkommen Homepage zählen (Parser oder Blocky)

    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      deAchte last edited by

      Hallo,

      ich wollte auf einer Homepage das Vorkommen, also die Anzahl von einem bestimmten Wort Zählen, da sich die Anzahl ändert.
      Kann ich das mit Parser umsetzten?
      Ich habe es schon mit einem Blocky versucht hab das aber wegen Misserfolg verworfen.
      Vielen dank im Voraus.
      Gruß
      Christian

      1 Reply Last reply Reply Quote 0
      • OliverIO
        OliverIO last edited by

        @deachte

        das geht nur mit skript
        einfach nur search_url und search_word einstellen.

        const axios = require('axios').default;
        
        
        //configure here
        const search_word="lorem";
        const search_url="https://www.loremipsum.de";
        //configure here
        
        async function  getWebContent(url) {
            const response = await axios.get(url);
            return response.data;
        }
        function countWord(content,word) {
        const re = new RegExp(word,"g");
          return ((content || '').match(re) || []).length
        }
        
        async function  main() {
        const content=await getWebContent(search_url);
        const count = countWord(content,search_word);
        console.log(count);
        }
        
        main();
        
        D 1 Reply Last reply Reply Quote 0
        • D
          deAchte @OliverIO last edited by

          @oliverio Das funktioniert!
          Wie kann ich das in einem Objekt ausgeben?

          OliverIO 1 Reply Last reply Reply Quote 0
          • OliverIO
            OliverIO @deAchte last edited by

            @deachte

            ich habe erweitert.
            den namen deines datenpunkts eintragen.
            den datenpunkt bitte vorher selber manuell anlegen

            const axios = require('axios').default;
            
            
            //configure here
            const search_word="lorem";
            const search_url="https://www.loremipsum.de";
            const search_dp="0_userdata.0.test3";
            //configure here
            
            async function  getWebContent(url) {
                const response = await axios.get(url);
                return response.data;
            }
            function countWord(content,word) {
                const re = new RegExp(word,"g");
                return ((content || '').match(re) || []).length
            }
            
            async function  main() {
                const content=await getWebContent(search_url);
                const count = countWord(content,search_word);
                console.log(count);
                setState(search_dp,count);
            }
            
            main();
            
            D 1 Reply Last reply Reply Quote 0
            • D
              deAchte @OliverIO last edited by

              @oliverio said in Vorkommen Homepage zählen (Parser oder Blocky):

              setState(search_dp,count);

              Funktioniert! Vielen dank!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              Support us

              ioBroker
              Community Adapters
              Donate
              FAQ Cloud / IOT
              HowTo: Node.js-Update
              HowTo: Backup/Restore
              Downloads
              BLOG

              533
              Online

              31.9k
              Users

              80.2k
              Topics

              1.3m
              Posts

              2
              5
              210
              Loading More Posts
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes
              Reply
              • Reply as topic
              Log in to reply
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
              The ioBroker Community 2014-2023
              logo