Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.15.0 is available! For more information about this release, check out this topic.

    Loading and selecting an external DOM Element with jsdom

    Development
    2
    5
    395
    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.
    • A
      anyhowat last edited by

      Hi,

      I’m trying to write a module which loads a DOM-element of a remote URL with JSDOM.
      https://github.com/anyhow/MMM-scrape

      Example usecase: Displaying the current onair artistname and songtitle of a radio station.
      (In the example: The Span-Elements with the class “playing” at https://fm4.orf.at/player/live)

      @fewieden did something similar before, but I’m not able to adapt it:
      https://github.com/fewieden/MMM-VocabularyTrainer/blob/master/apis/geschichtsvereinkoengen.js#L89

      I can’t get jsdom to work at all. Anybody could have a look and have some tips? Do I need to put it into a node_helper?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • S
        sdetweil last edited by sdetweil

        i can work on it more in a couple hours… (grandson socker game)

        I misread it in a hurry…
        worked thru it, further down

        1 Reply Last reply Reply Quote 0
        • S
          sdetweil last edited by

          Also, you can’t use require in the module.js

          Only in node_helper.

          Turn on the developers window, ctrl-shift-i , and select the console tab and scroll up to see any errors

          1 Reply Last reply Reply Quote 0
          • S
            sdetweil last edited by sdetweil

            @anyhowat i updated your code to a small working sample… i created a pull request back to you with the updates

            but the node you are looking for on the site (span.playing) does not exist.
            I added debugging to dump the content returned from the jsdom api request

            also, after installing your module (or pulling my updates after merge), you need to do

            npm install
            

            in the module folder, to get the jsdom library loaded from your module

            1 Reply Last reply Reply Quote 0
            • A
              anyhowat last edited by

              Sam, thanks. That’s awesome.
              I’ll dig into the changes right now. Made my day.

              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 Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy