Perfume + coding? Worlds collide!
You give a perfume nerd too much time and the ability to code and this is what she does...
One of my all-time favorite complements is being told I smell nice. Perfume has interested me for so long and trying new fragrances just brings me so much delight. Fun fact: My first ever perfume was Enchanting by Céline Dion and I miss that sucker to this very day!
Recently I came across Parfumo, a perfume community website. There are others, but the biggest name in the game... well... let's just say they do not align with my values. Parfumo is well designed, full of great information and reviews on nearly any perfume you can think of, and has a really nice way to build various collections on your profile. One feature I find cute is the ability to note what perfume you're actively wearing. This information is stored on the site so you can look back on what you wear most (and least) and helps Parfumo suggest new perfumes that align with your tastes. Plus their iOS app makes it so quick and easy to log my perfume each day after I put one on!

On my personal website I want people to get a "taste" of who I am. There are a variety of ways I try to show that, from showcasing my work to writing a little bio that hits on my interests. A few days ago I was thinking, "What if I could put what perfume I'm wearing each day on my site?" and well, that just had to happen.
Parfumo doesn't have an API (APIs are, in very simple terms, a way for computer programs to communicate with each other) which meant I'd need to be a little crafty with how to get this information from my user profile and onto my personal website!




Code! From top left clockwise: The script I wrote, the docs for the web scraper package, the implementation code for my about page, and the Github code repository for the final script
I decided to use a web scraping package for the PHP coding language called hQuery. Web scrapers allow developers to load up any webpage within their code and traverse the webpage to find what they may be looking for. Be that images, links, text, et cetera.
With hQuery set up I was able to first load my Parfumo profile page and locate the link to the current perfume being worn. Second I loaded the Parfumo perfume page from that link and could grab the perfume's name and brand. At that point I had everything I needed! The single-file script would then give whatever was requesting the information (the about page of my website in this case) the perfume's name, brand, and a URL to the perfume's details page!
On the about page of my website I wrote a small bit of JavaScript that makes a request to the perfume of the day script (using the fetch function asynchronously), waits for the response, then formats the information and adds it to the page. Bam! Perfume on my about page! If no perfume is actively being worn, the script tells the about page that too so that no perfume information is shown.

You can find the code for this little script on my Github! And you can see it in action on the about page of my website!
I feel like little details matter. For this, I hope it gives a timely, quirky little look into my life.
As for my perfume collection? I'm currently obsessed with Fire by The Maker, which was a Christmas gift from my grandmother! I'm also really into Devotion Intense by Dolce & Gabbana and You Doux by Glossier. Those two I only have as samples at the moment but I am thinking about buying them once I run out! And I can't leave out one of my long-time and all-time favorites: Euphoria by Calvin Klein. I don't know if I have a "signature" fragrance, but this would probably be it.
Okay, until next time! I hope you find or make yourself some delight today!