Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Daten aus PW geschützte Website

    NEWS

    • ioBroker goes Matter ... Matter Adapter in Stable

    • 15. 05. Wartungsarbeiten am ioBroker Forum

    • Monatsrückblick - April 2025

    Daten aus PW geschützte Website

    This topic has been deleted. Only users with topic management privileges can see it.
    • Negalein
      Negalein Global Moderator @Latzi last edited by

      @latzi sagte in Daten aus PW geschützte Website:

      über einen kleinen Arbeitgeber in Linz,

      Mannoooo, der Siedlerverein ist dann schlechter beim Verhandeln gewesen. 😞
      Hmmm, gib mir euer Kennwort. Dann bin ich halt auch bei der Voest! 😂 😂

      Latzi 1 Reply Last reply Reply Quote 0
      • Latzi
        Latzi @Negalein last edited by

        @negalein
        wir suchen immer fähige Mitarbeiter, überleg´s dir 😉 ... und mit dem niedrigeren Spritpreis ist die Anfahrt auch abgedeckt

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

          @latzi

          hm, response sieht gut aus.
          es kommen sonst keine Fehlermeldungen?
          stell bitte das skript mal auf verbose (oben rechts der schraubenschlüssel)

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

            @oliverio

            ich hab einzeln und auch beide Optionen aktiviert
            cf1fdb3d-f1b2-4ec3-96b3-bfb962261ac5-grafik.png
            Im log tauchen aber keinerlei Informationen auf (außer Stop und Start des Skripts:

            2022-12-09 14:13:37.307 - info: javascript.0 (504) Stop script script.js.common.Spritpreis_IQ
            2022-12-09 14:13:37.458 - info: javascript.0 (504) Start javascript script.js.common.Spritpreis_IQ
            2022-12-09 14:13:37.462 - info: javascript.0 (504) script.js.common.Spritpreis_IQ: registered 0 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
            

            Kann ich cheerio.load(body) über die Konsole loggen oder kommt da nur Mist? Ich vermute, dass cheerio da Probleme macht, in node_modules ist es zumindest enthalten.

            Edit:
            Ich hab´s versucht, es kommt Mist 😉

            022-12-09 14:30:12.212 - info: javascript.0 (504) Start javascript script.js.common.Spritpreis_IQ
            2022-12-09 14:30:12.259 - info: javascript.0 (504) script.js.common.Spritpreis_IQ: registered 0 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
            2022-12-09 14:30:13.165 - info: javascript.0 (504) script.js.common.Spritpreis_IQ: function initialize(selector, context, root, opts) {
            if (root === void 0) { root = initialRoot; }
            // $($)
            if (selector && (0, utils_js_1.isCheerio)(selector))
            return selector;
            var options = __assign(__assign({}, internalOpts), (0, options_js_1.flatten)(opts));
            var r = typeof root === 'string'
            ? [parse(root, options, false, null)]
            : 'length' in root
            ? root
            : [root];
            var rootInstance = (0, utils_js_1.isCheerio)(r)
            ? r
            : new LoadedCheerio(r, null, options);
            // Add a cyclic reference, so that calling methods on `_root` never fails.
            rootInstance._root = rootInstance;
            // $(), $(null), $(undefined), $(false)
            if (!selector) {
            return new LoadedCheerio(undefined, rootInstance, options);
            }
            var elements = typeof selector === 'string' && (0, utils_js_1.isHtml)(selector)
            ? // $()
            parse(selector, options, false, null).children
            : isNode(selector)
            ? // $(dom)
            [selector]
            : Array.isArray(selector)
            ? // $([dom])
            selector
            : undefined;
            var instance = new LoadedCheerio(elements, rootInstance, options);
            if (elements) {
            return instance;
            }
            if (typeof selector !== 'string') {
            throw new Error('Unexpected type of selector');
            }
            // We know that our selector is a string now.
            var search = selector;
            var searchContext = !context
            ? // If we don't have a context, maybe we have a root, from loading
            rootInstance
            : typeof context === 'string'
            ? (0, utils_js_1.isHtml)(context)
            ? // $('li', '
            
               ...
            
            ')
            new LoadedCheerio([parse(context, options, false, null)], rootInstance, options)
            : // $('li', 'ul')
            ((search = "".concat(context, " ").concat(search)), rootInstance)
            : (0, utils_js_1.isCheerio)(context)
            ? // $('li', $)
            context
            : // $('li', node), $('li', [nodes])
            new LoadedCheerio(Array.isArray(context) ? context : [context], rootInstance, options);
            // If we still don't have a context, return
            if (!searchContext)
            return instance;
            /*
            * #id, .class, tag
            */
            return searchContext.find(search);
            }
            

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

              @latzi

              zeig mir bitte mal dein skript genau so wie es nicht läuft (die zeilen mit passwort und user kannst du löschen

              ich habe gerade festgestellt, sobald ich
              console.info mache oder irgend etwas ausgebe, was anscheinend dem adapter nicht passt, bricht das skript ohne fehlermeldung ab.

              cheerio mit $ ausgeben zu lassen amcht nicht viel sinn, da das objektmodell doch etwas umfangreicher ist und das nicht soviel spaß macht zu lesen.
              cih schau mir das immer im debugger von vs code an.
              bei dir kommt aber lustigerweiße eher der source von cheerio als das objektmodell

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

                @oliverio
                hier mein Skript:

                const dpPrices = "javascript.0.IQ.Treibstoff_Preis";
                var user = "xxx";
                var pass = "yyy";
                
                const request = require("request");
                const cheerio = require("cheerio");
                
                async function main() {
                
                 var optionsLogin = {
                   method: 'POST',
                   url: "https://netservice.iqcard.at/de/login",
                   body: "BENUID=" + user + "&PASSWT=" + pass + "&login-form-submit=login",
                   jar: true,
                   followRedirect:true,
                   followAllRedirects :true,
                   headers: {
                     "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                     "accept-encoding": "gzip, deflate, br",
                     "accept-language": "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7",
                     "cache-control": "no-cache",
                     "content-type": "application/x-www-form-urlencoded",
                     "dnt": "1",
                     "origin": "https://netservice.iqcard.at",
                     "pragma": "no-cache",
                     "sec-ch-ua": "\"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"",
                     "sec-ch-ua-mobile": "?0",
                     "sec-ch-ua-platform": "\"Windows\"",
                     "sec-fetch-dest": "empty",
                     "sec-fetch-mode": "cors",
                     "sec-fetch-site": "same-origin",
                     "upgrade-insecure-requests": "1",
                     "User-Agent": " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
                     "cookie": "cAccept=true; NETSERVICE=true; IQCARDPASSWT=; IQCARDBENUID= ",
                     "Referer": "https://netservice.iqcard.at/de/kunden"
                   }
                 };
                 var optionsPriceinfo = {
                   method: 'GET',
                   url: "https://netservice.iqcard.at/de/netservice_preisinfo",
                   jar: true,
                   followRedirect:true,
                   followAllRedirects :true,
                   headers: {
                     "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                     "accept-encoding": "gzip, deflate, br",
                     "accept-language": "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7",
                     "cache-control": "no-cache",
                     "dnt": "1",
                     "origin": "https://netservice.iqcard.at",
                     "pragma": "no-cache",
                     "sec-ch-ua": "\"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"",
                     "sec-ch-ua-mobile": "?0",
                     "sec-ch-ua-platform": "\"Windows\"",
                     "sec-fetch-dest": "empty",
                     "sec-fetch-mode": "cors",
                     "sec-fetch-site": "same-origin",
                     "sec-fetch-user": "?1",
                     "upgrade-insecure-requests": "1",
                     "User-Agent": " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
                     "Referer": "https://netservice.iqcard.at/de/netservice"
                   }
                 };
                 request.jar();
                 request.post(optionsLogin,()=>{
                   request.get(optionsPriceinfo,(error, response, body)=>{
                     const $ = cheerio.load(body);
                     //console.log(cheerio.load(body));
                     let titles = $('div[class="panel-body"] > fieldset > legend > strong').map((i,el)=>$(el).text().replace("Preise","").trim());
                     let dates = $('div[class="panel-body"] > fieldset').contents().filter(function() {
                       return this.nodeType == 3 && this.data.replace(/\s/gm,"")!=""
                     }).map((i,el)=>$(el).text().replace(/\s/gm,"").slice(0,-1));
                     let prices = $('div[class="panel-body"] > fieldset > strong').map((i,el)=>$(el).text());
                     if (titles.length==dates.length && titles.length==prices.length) {
                       console.debug("website structure OK, found matching elements");
                     } else {
                       console.debug("website structure is not OK, elements doesnt match");
                       return;
                     }
                     let data={};
                     for (var i=0;i<titles.length;i++) {
                       data[titles[i]]={
                         title:titles[i],
                         date:dates[i],
                         price:prices[i]
                       };
                     };
                     console.debug(data);
                     writeDatapoint(data);
                   });
                 });
                 function writeDatapoint(data) {
                   console.debug("write dpPrices");
                   setState(dpPrices,JSON.stringify(data));
                 }
                }
                
                //schedule("5 21 * * 1", async function () {
                  main();   
                //});   
                
                

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

                  @latzi sagte in Daten aus PW geschützte Website:

                  also dein skript genommen und die benutzerdaten von negalein verwendet
                  funktioniert einwandfrei.
                  da du den response gepostet hast, in dem auch die kosten enthalten waren,
                  scheint es tatsächlich an cheerio zu liegen.

                  geh am besten mal in die einstellungen des javascript adapters und entferne dort das cheerio paket wieder, dann speichern, dann den kompletten javascript adapter stoppen und neu starten,
                  dann cheerio wieder hinzufügen und dann nochmal probieren

                  wenn es dann immer noch nicht funktioniert, machen wir mit cheerio mal einen ganz einfachen test. aber erst mal das

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

                    @oliverio sagte in Daten aus PW geschützte Website:

                    geh am besten mal in die einstellungen des javascript adapters und entferne dort das cheerio paket wieder, dann speichern, dann den kompletten javascript adapter stoppen und neu starten,
                    dann cheerio wieder hinzufügen und dann nochmal probieren

                    funktioniert leider immer noch nicht 😞

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

                      @latzi

                      dann in neuen skript das folgende eintragen

                      const cheerio = require('cheerio');
                      const $ = cheerio.load('<h2 class="title">Hello world</h2>');
                      
                      $('h2.title').text('Hello there!');
                      $('h2').addClass('welcome');
                      
                      $.html();
                      

                      zusätzlich noch debug und verbose einschalten

                      als Ergebnis muss im skriptlog folgendes erscheinen

                      15:18:58.522	debug	javascript.0 (3875) script.js.Test.test: <html><head></head><body><h2 class="title welcome">Hello there!</h2></body></html>
                      
                      Latzi 3 Replies Last reply Reply Quote 0
                      • Latzi
                        Latzi @OliverIO last edited by

                        @oliverio
                        tja, da haben wir wohl den Übeltäter, es kommt wieder genau gar nichts 😞
                        Anbei noch meine anderen Module im Adpater (falls sich da etwas in die Quere kommt):
                        98ece855-6ddd-47c6-a444-bd4c908a9fed-grafik.png
                        Kann ich das Modul irgendwie händisch löschen und neu installieren?

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

                          @oliverio
                          selbst wenn ich cheerio aus dem Adapter entferne und neu starte läuft das Testscript ohne Fehlermeldung durch???

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

                            @oliverio

                            cheerio kommt irgendwie mehrfach vor, soll das so sein?

                            latzi@ioBroker:/opt/iobroker$ npm list cheerio
                            iobroker.inst@3.0.0 /opt/iobroker
                            ├── cheerio@1.0.0-rc.12
                            ├─┬ iobroker.javascript@6.1.4
                            │ └── cheerio@1.0.0-rc.12
                            └─┬ iobroker.smartcontrol@1.3.2
                              └── cheerio@1.0.0-rc.12 deduped
                            
                            latzi@ioBroker:/opt/iobroker$
                            
                            OliverIO 1 Reply Last reply Reply Quote 0
                            • OliverIO
                              OliverIO @Latzi last edited by

                              @latzi

                              das ist erstmal ok. das ist das prinzip von node, so das jedes paket genau die version lädt mit der ein paket funktioniert.

                              evtl musst da mal im forum genereller fragen, wie man das analysieren kann und warum bestimmte pakete da ohne fehlermeldung nicht geladen werden oder nicht richtig funktionieren.
                              hast du den javascript adapter mal in der instanz übersicht im expertenmodus auf debug umgestellt? evtl kommt dann was wenn man paket hinzufügt oder entfernt

                              Latzi F 2 Replies Last reply Reply Quote 0
                              • Latzi
                                Latzi @OliverIO last edited by

                                @oliverio
                                vielen Dank für deine unermüdliche Hilfestellung!

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

                                  @oliverio hier bringt das Testskript auch keine Ausgabe. Nur bei log($.html()) kommt die Ausgabe und zeigt damit an dass cheerio funktioniert

                                  8:58:53.486	info	javascript.1 (195) Start javascript script.js.testCheerio
                                  18:58:53.495	info	javascript.1 (195) script.js.testCheerio: <html><head></head><body><h2 class="title welcome">Hello there!</h2></body></html>
                                  18:58:53.496	info	javascript.1 (195) script.js.testCheerio: registered 0 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
                                  
                                  OliverIO Latzi 2 Replies Last reply Reply Quote 0
                                  • OliverIO
                                    OliverIO @fastfoot last edited by OliverIO

                                    @fastfoot
                                    @Latzi

                                    Äh ja ich war irritiert, ich dachte ich hatte im testscript das in

                                    console.debug($.html());
                                    

                                    Noch abgeändert

                                    Bitte nochmal probieren

                                    Latzi 1 Reply Last reply Reply Quote 0
                                    • Latzi
                                      Latzi @fastfoot last edited by

                                      @fastfoot
                                      aarghhh, das funktioniert bei mir jetzt auch 👍

                                      @OliverIO was sagt uns das nun?

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

                                        @latzi

                                        Bin jetzt unterwegs.
                                        Kann nur beschwert tippen

                                        Titles Dates und prices sind Array s
                                        Lass dir da mal die Länge raus
                                        Sie müssen alle gleich sein
                                        Am besten vor der if Abfrage einfügen
                                        Ansonsten nach jeder Zeile mal irgendeine Test Ausgabe auf die console machen das wir sehen wie weit das Skript kommt

                                        Latzi 2 Replies Last reply Reply Quote 0
                                        • Latzi
                                          Latzi @OliverIO last edited by

                                          @oliverio sagte in Daten aus PW geschützte Website:

                                          console.debug($.html());

                                          witzig, damit funktioniert´s bei mir nicht, wenn ich console.log($.html());nehme bekomme ich die erwartete Ausgabe - ich versteh´s nicht!

                                          F 1 Reply Last reply Reply Quote 0
                                          • F
                                            fastfoot @Latzi last edited by

                                            @latzi ist hier auch so, console.info etc. funktionieren in iobroker nicht. Einfach durch log(text) ersetzen

                                            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

                                            926
                                            Online

                                            31.6k
                                            Users

                                            79.5k
                                            Topics

                                            1.3m
                                            Posts

                                            7
                                            126
                                            7149
                                            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