When I was starting out, I never understood how to tackle 'projects'. It was hard to understand the scope of a project from a glance, as well as th...
For further actions, you may consider blocking this person and/or reporting abuse
Great post describing the full process from idea to production. Also I didn't hear about Glitch before your post. It's so easy to develop and deploy Node apps on Glitch!
I'm just curious why did you choose to use
puppeteer
for scraping. I thought it's more suitable for end-to-end tests. I think it adds extra complexity by introducing a browser's launch/exiting, sandboxes, page evaluating.Maybe it'll be better to use a fetch library (like
request
) to fetch the MDN page and parse it withcheerio
in jQuery style?Thanks Eugene π
I had only scraped with Python before but wanted this project to be all JavaScript. So I googled and went with one of the first results. Thanks for the recommendations!
The first ideas that come to my mind to prevent the script from randomly picking the same entry twice for the current session at least, I would remove the chosen item from the choice pool or keep a memory of chosen items
Using the current session is an interesting way of solving it! Nice idea. β¨
As for the unlikely but possible chance of getting the same link twice in a row, you could create a small array of the last few links generated, and tell the function to choose a new random link if it matches any link in the array. This array would also allow for some additional functionality (like an βoopsβ button allowing you to go back to the last link when youβve accidentally clicked to generate a new link when you saw one you were interested in.) Maybe thatβs a bit more than necessary, or maybe you could expand on that a little further even. JM2C
I like this idea. I think Iβd prefer to do it on the client even if itβs +1 request (rarely) as you described.
I like the state idea too, the βoopsβ button is cool π