Comments (4)
@tshoyo thanks for digging into the problem and proposing a solution. A pull request would be much appreciated! 🙏
from cookbook.
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.
@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.
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)
- Filter by tag/category my means of updating the filter string
- Enhancements to the cook view HOT 1
- No 4 columns in UI
- Add check if User changelog is needed
- Add ERP-like stock management
- Number of categories differs between the GUI and the API
- Error downloading recipe from URL
- allow ingredients withou amount
- ingredient amounts given as intervals are not treated properly
- There are a lot of Spaces, and unnecessary newlines when converting to print/pdf
- a lot of unnecessary newlines and page breaks on print out/pdf HOT 1
- Cookbook not seeing recipes in recipes folder HOT 1
- Fraction to Decimal Conversion for Ingredients As Toggle Option HOT 1
- Restore Enter/Return Key Function For Creating New Ingredients & Steps HOT 2
- Do not redownload the url-image HOT 1
- Integrating RecipeClipper as a recipe parser HOT 1
- Add recipe ID to recipe stubs
- Cookbook does compatible Nextcloud 28 ? HOT 4
- Changing the recipe folder has no effect HOT 1
- Recipe API provides wrong date format with `/api/v1/recipes`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookbook.