• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Loading and selecting an external DOM Element with jsdom

Scheduled Pinned Locked Moved Development
5 Posts 2 Posters 799 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.
  • A Offline
    anyhowat
    last edited by Oct 5, 2019, 1:04 PM

    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 Offline
      sdetweil
      last edited by sdetweil Oct 6, 2019, 11:46 AM Oct 5, 2019, 1:34 PM

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

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

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil
        last edited by Oct 5, 2019, 6:53 PM

        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

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil
          last edited by sdetweil Oct 5, 2019, 9:27 PM Oct 5, 2019, 9:26 PM

          @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

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • A Offline
            anyhowat
            last edited by Oct 6, 2019, 10:57 AM

            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
            1 / 1
            • First post
              1/5
              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