Open comments for this post
Scraping & Parsing logic fully complete!
After a lot of work, I converted the code from printing the recipe onto the console to returning it as a JsonObject. This will ideally allow me to use an api to fetch it from a frontend website.
I tested the program with various recipe websites and they all seem to work! Originally, I was having trouble with website security features but through the use of selenium I was able to get past to the website.
For the next devlog I hope to be done API integration, and some basic front end testing.
Open comments for this post
Ingredients can now print on the console
I have just finished a prototype version where, when given a recipe link, the ingredients of the recipe are printed. This took a lot of time, and I had to change what package i used to make it work. The trick to make this work really boiled down into the fact that most recipe websites store their data in json. As a result, this is really easy to scrape and extract. Here is an example of the ingredients of some chocolate brownies printing in the console.
Open comments for this post
Website Scraper
Through the use of the JSoup java library I tried implementing a website scraper, witch takes all of the elements on a website and displays it as plain text on the console. This method worked for less secure sites such as wikipedia, but on most recipe sites that may use cloudflare it did not work. This is likely due to the anitscraping measures cloudflare has set. To work around this I may play around with other java libraries that usually have a higher success rate.
Also, I don’t know why my coding time saved under the ‘user’ project in hackatime rather than a frictionless project. If anyone can help with that, that would be lovely.
Open comments for this post
Added the riddle to the bot and made it run 24/7
Ran into a couple bugs today.
Bug 1:
put the wrong working directory for the nest server to reference. Since this directory did not exist, the server could not run the slack bot. To fix this, i simply got the directory of the slack bot and put that in as the working directory
Bug 2:
Issues with correct answer validation
If the answer to one of the riddles was Seven for example, and the user guessed Seven, the slack bot would mark that as incorrect. While debugging, I realised that this issue was caused by the usage of the toLowerCase() string function. I was making the users answers lowercase resulting in the code comparing the correct answer “Seven” with “seven” and deeming that as incorrect. To fix this I simply changed all the answers to lowercase strings
Open comments for this post
Built a slack bot that can run predefined riddles.
To achieve this i set an array with the riddle questions and their answers. Than, I added two commands, one to display the riddle, and the other to get the users response and display wether the user was correct or not. The bot has not been tested yet, nor have the final riddles been added. All of this will be done once nest application is approved
Open comments for this post
Created the schematic for my macropad