Having a collection of flags is cool. But, what's even cooler is getting a representing embassy to send you their flag and show appreciation that you're interested in their culture. I could've compiled a list of emails for different embassies and sent out emails to each individually, but that defeats the purpose of being a computer engineer. Gotta automate the process! The main idea was inspired by this video.
The course of action taken was as follows: Find a database that contains contact information for several embassies in Canada. Then, write a web-scraping script to get the list of emails. And finally, write a script that sends out emails to all addresses in the list.
The code was written in Python since it's very simple to use for developing algorithms that automate the extraction and processing of large amounts of data from a website.
At first, I had to compile a list of URLs that contain different embassy contact information since it was compiled under one web page. Then, say for example when inspecting that
contains the email address had the following html tag:
<li> id="email"><span class="label">Email</span>myaddress@Email.com</li>
, then getting the field value would look something like this:
email = driver.find_element_by_id('email')
And just like that, I sent out 582 emails to every single representing country.
The question you might be asking now is, did I actually get any flags? Well, no.
I've just been receiving rejection emails, but most of them are being really appreciative. I'm actually surprised they are responding to these type of emails since the original video has become popular and everybody is probably doing the same thing. However, the point was just a quick fun over the weekend to-do project during incubation because of COVID-19. Hope you all stay safe!
UPDATE!!: I actually received the Russian flag from the Russian embassy in Montreal.