Giter VIP home page Giter VIP logo

Comments (4)

mrzapp avatar mrzapp commented on June 15, 2024

@tshoyo thanks for digging into the problem and proposing a solution. A pull request would be much appreciated! 🙏

from cookbook.

 avatar commented on June 15, 2024

So, as I was adding in the header fix, the URL I was using was able to successfully fetch the html, but it kept throwing a type conversion error. I realized that the website uses a div element rather than an article element to host the actual recipe data. This would mean the html parser would need to be improved upon for this use case.

However, I feel that using regex to parse html is not maintainable and would like to pursue a different route before messing with the current parser. It would be much better to utilize a DOM tree library to traverse the html, but I understand if there is a desire to keep dependencies to a minimum. This begs the question, is there any particular reason for fetching the recipe data server-side?
Javascript has a built in DOM parser with the addition of JQuery to make traversal that much more trivial. We could just request the target URL with $.ajax() and then search the html for recipe data.

This will increase the effectiveness of the parser without adding an additional library dependency. Worst comes to worst, we can fall back to the server-side parser if the Javascript one fails. Let me know what your thoughts are @mrzapp!

from cookbook.

mrzapp avatar mrzapp commented on June 15, 2024

@tshoyo You're right, regex parsing is a huge pain, but trying to fetch the HTML with JSON alone would most certainly throw a CORS error. We could fetch the HTML using PHP and then parse it using JavaScript.

There is also the built-in XMLParser in PHP, which should work. I would have no problem including a library though, since it's such a big part of this app.

I don't have a lot of time to work on this, so I can't afford to be picky on how problems are solved. As long as we're not making the code base unreadable or screwing up the UI, I'll be happy to include any improvements you can contribute in upcoming releases :)

from cookbook.

 avatar commented on June 15, 2024

Lol ah I am yet to learn my lesson about CORS after all the times it's bitten me in the butt. I will see if I can make the XML parser work out, otherwise, I might try a library that uses JQuery-like syntax.

from cookbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.