• 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.

SampleCode for Module to read a specific Information from a webpage

Scheduled Pinned Locked Moved Development
19 Posts 4 Posters 2.0k Views 3 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.
  • S Offline
    sdetweil @newbi
    last edited by Feb 21, 2025, 7:15 PM

    @newbi describe more, reading specific info

    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 @newbi
      last edited by sdetweil Feb 21, 2025, 8:50 PM Feb 21, 2025, 8:44 PM

      @newbi

      you can fetch the page html and then
      use the cheerio lib to extract the html part of the page

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • N Offline
        newbi
        last edited by Feb 21, 2025, 9:15 PM

        @sdetweil, well on a webpage of a gym, there is an information how many people are in the gym. I want to show this Information on my MagicMirror. Thats all.

        Can you provide me a sample code?
        I am not firm with programming in javascript an libs. My programming experience is business based.

        Or is there a module i can use?

        How to fetch a html-Page?
        How to extract? I thougt i can search the page for a keyword, where the wanted value is nearby. Dirty but hopfuly worky ;)

        S C 3 Replies Last reply Feb 21, 2025, 11:53 PM Reply Quote 0
        • S Offline
          sdetweil @newbi
          last edited by sdetweil Feb 22, 2025, 12:09 AM Feb 21, 2025, 11:53 PM

          @newbi well, compliments does fetch, helloworld is a simple module

          my sample module is full function, but you wont need a node_helper as fetch works browser

          https://github.com/sdetweil/SampleModule

          cheerio is a nodejs lib you can find in npmjs , and will require the node_helper, so best to combine fetch and cheerio there

          the module development doc is here
          https://docs.magicmirror.builders/development/introduction.html

          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 @newbi
            last edited by Feb 22, 2025, 1:27 AM

            @newbi we will help you if you get stuck making it work, but wont write it for you

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • N Offline
              newbi
              last edited by Feb 22, 2025, 9:42 AM

              @sdetweil, ok, thanks so far, i will try to get firm with the basics.
              As i am working on my Windows Laptop, having a MagicMirror on a Raspy 3, can i develope on my Laptop or do i need to create a developement environment on my raspy (or on my Windows Laptop)?

              S R 2 Replies Last reply Feb 22, 2025, 1:47 PM Reply Quote 0
              • C Offline
                chrisfr1976 @newbi
                last edited by chrisfr1976 Feb 22, 2025, 10:40 AM Feb 22, 2025, 10:40 AM

                @newbi
                If you want to display how crowded yor gym is, use HTML Snippet or SmartWebDisplay. Cheerio is more for static pages useful. If yor gym does not block iframes thi is the easiest way imho.

                Regards, Chris.

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @newbi
                  last edited by sdetweil Feb 22, 2025, 2:19 PM Feb 22, 2025, 1:47 PM

                  @newbi MagicMirror runs on windows

                  need to follow the install instructions

                  need nodejs (20.18.1, or 22 up)
                  git

                  there is a separate start script for windows

                  npm run start:windows

                  also see
                  https://forum.magicmirror.builders/post/121672

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    rkorell @newbi
                    last edited by Feb 22, 2025, 6:01 PM

                    @newbi asked

                    can i develope on my Laptop or do i need to create a developement environment on my raspy

                    Dear @newbi ,
                    neither, nor :-)
                    You can “develop” physically on your laptop but the files (should) remain on the Raspi.
                    On the Raspi therefore you do not need a “development” environment.
                    You need a FTP Browser - connect this one via SFTP to the Raspi (SSH should be enabled on the Raspi - then SFTP works inherently).

                    Than you click right on the remote (Raspi) File(s) you need to modify and open the file(s) with a (Laptop) local editor of your choice.
                    When changes are done, save the file and restart the mirror - then you see the changes.

                    At least this is the way as I do those things - currently NOT programming but changing custom.css and config.js.

                    I am on a Windows laptop in most cases and I use BitVize for FTP and SSH and Sublime as Editor (which is for “programmers” because several “languages” are marked up nicely).
                    For a quick view on the result I use VNC-Viewer which gives me a better view because I have my display in portrait format which isn’t displayed nicely in Webbrowser).

                    HTH
                    Regards,
                    Ralf

                    1 Reply Last reply Reply Quote 0
                    • N Offline
                      newbi
                      last edited by Feb 23, 2025, 11:26 AM

                      @chrisfr1976 thanks for giving me the two modules :)
                      The first one seems to be promising. But I struggle to get the page been shown.
                      Is it possible to show a page?
                      And is it possible just to show the content of

                      with a class name thats locatet somehere on the page?
                      If not, i will stopp my effords and enjoy what i got so far, but it would be nice to get this information on the screen.

                      @rkorell, well newbi to programming or confuguring a mirror. Not now to programming at all, but i do it in a completele different environment (more old school).
                      I do nothing with webpages, nopthing with javascript, no libraries.
                      My Configuration does work well, i do it wie ssh. not the best way, but the result is good.

                      S 1 Reply Last reply Feb 23, 2025, 2:15 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        6/19
                        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