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

Help developing first module, displaying webscraped text.

Scheduled Pinned Locked Moved Development
8 Posts 3 Posters 985 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.
  • E Offline
    enderflop
    last edited by Jan 21, 2022, 4:27 AM

    Sorry in advance for my code, I know extremely little Javascript but I like to think I’m pretty decent at Python. I’ve made a functioning webscraper in Python, transfered it to Javascript, but now I’m running into errors implementing it into a module and displaying it on my mirror.
    The code for it is here on my github.
    Only the dining-hall folder is in my modules folder and I’ve npm installed both dependencies (axios and cheerio). My config file has no syntax errors and I think it is set up correctly.
    72da62f6-53c9-4b1b-8fd8-6b04c5869130-image.png I’m currently running into the error in the following screenshot when trying to get the module to display.
    7d766f67-4ad3-4243-8769-2baadb7ea534-image.png
    The errors continue on for a while.
    I have no idea where to start debugging. Please tear apart my code, call me an idiot or whatever, I’m just looking to get this solved and learn something along the way. Thanks for your help! I’ll be around to respond and give any additional materials that might help. By the end I would like to not only have the module displaying, but also displaying the correct information. I might need some help with notification and payload transfer lol. Thanks for everything!

    C S 3 Replies Last reply Jan 22, 2022, 4:37 PM Reply Quote 0
    • C Offline
      cowboysdude Module Developer @enderflop
      last edited by Jan 22, 2022, 4:37 PM

      @enderflop No one is going to call you an idiot. The very first error is easy because it cannot find the file you are trying to load.

      what is mmpm.js? That’s the file it can’t find.

      S 1 Reply Last reply Jan 22, 2022, 11:15 PM Reply Quote 0
      • S Offline
        sdetweil @enderflop
        last edited by Jan 22, 2022, 11:13 PM

        @enderflop nice start…

        sorry, yuou can’t do require() in the browser side (dining-hall.js)
        only n the server side (node_helper)

        so the layout looks right… and you’ve got the flow correct…
        send request to node_helper
        it processes, gets data
        sends back to modulename.js
        and then it does updateDom()
        and getDom() builds the html /dom content…

        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 @cowboysdude
          last edited by Jan 22, 2022, 11:15 PM

          @cowboysdude mmpm is another module… disable that in config.js for now

          module: mmpm,
          disabled: true

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 1
          • S Offline
            sdetweil @enderflop
            last edited by Jan 23, 2022, 12:32 AM

            @enderflop i tested your module, a couple tiny changes

            submitted a PR with the updates…

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            E 1 Reply Last reply Jan 23, 2022, 1:22 AM Reply Quote 0
            • E Offline
              enderflop @sdetweil
              last edited by Jan 23, 2022, 1:22 AM

              @sdetweil Hey, sorry for the late response. I accidentally took the screenshot of mmpm but the same error was coming up with dining-hall lol that’s a mistake. I’ll take a look at the PR and see how it goes, thanks!

              E 1 Reply Last reply Jan 23, 2022, 1:45 AM Reply Quote 0
              • E Offline
                enderflop @enderflop
                last edited by Jan 23, 2022, 1:45 AM

                Got it to work! Thanks for the PR @sdetweil and the example webscraping code @cowboysdude
                4ea51fcf-a566-4981-b99d-54bd250929a0-image.png

                S 1 Reply Last reply Jan 23, 2022, 1:58 AM Reply Quote 1
                • S Offline
                  sdetweil @enderflop
                  last edited by sdetweil Jan 23, 2022, 4:22 PM Jan 23, 2022, 1:58 AM

                  @enderflop cool

                  key here is module name = foldername = filename = register name
                  and node_helper.js has to be in the same folder

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 2
                  • 1 / 1
                  1 / 1
                  • First post
                    1/8
                    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