DEV Community

Cover image for A Tiny Project, From Inception to Deployment

A Tiny Project, From Inception to Deployment

Andrew Healey on May 12, 2019

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...
Collapse
 
karataev profile image
Eugene Karataev

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 with cheerio in jQuery style?

Collapse
 
healeycodes profile image
Andrew Healey

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!

Collapse
 
haamida profile image
Hamida

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

Collapse
 
healeycodes profile image
Andrew Healey • Edited

Using the current session is an interesting way of solving it! Nice idea. ✨

Collapse
 
rbleattler profile image
Robert Bleattler

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

Collapse
 
healeycodes profile image
Andrew Healey

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 πŸ‘