Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [Frage:] Webseite mit Format ISO-8859-1 einlesen

    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

    [Frage:] Webseite mit Format ISO-8859-1 einlesen

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

      Hallo zusammen,

      mit folgendem Script möchte ich den html-code einer web-Seite einlesen.

      function main() {
        let html = "";
        let https = require('https');
      
        const options = {
          hostname: 'www.abc.de',
          port: 443,
          path: '/efg/xyz.html',
          method: 'GET',
        };
      
        let req = https.request(options, function(res) {
            //res.setEncoding('utf-8');
            res.on("data", (chunk) => { html += chunk; });
            res.on("error", (e) => { console.error(e); });
            res.on("end", () => { tu_was(html); }); //tu_was aufrufen, wenn Seite in String 'html' importiert ist
          });
      
          req.on("error", (e) => { console.error(e); });
        req.end();
      }
      

      Das Problem ist, dass die betreffende Seite ISO-8859-1 codiert ist, während ioBroker die Seite als utf-8 interpretiert.

      Das führt leider dazu, dass alle Umlaute in ein Fragezeichen umgewandelt werden.

      Frage also an euch: wie kann ich ioBroker (bzw. Javascript) beibringen, dass ich eine ISO-8859-1-Seite einlesen möchte. res.setEncoding('iso-8859-1') (siehe Listing) funktioniert leider nicht.

      Gruß Joerg

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

      Support us

      ioBroker
      Community Adapters
      Donate

      624
      Online

      31.8k
      Users

      80.0k
      Topics

      1.3m
      Posts

      1
      1
      89
      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