It's important to be informed about what's happening and be able to track the progress of this virus in terms of confirmed cases, deaths and specially recoveries. That's why it came to mind to create this Twitter bot in order to track, in real-time, the progress of this disease.

What it does

Every 10 minutes, the bot parses the WorldOMeter website in order to get the total of confirmed cases, deaths and recoveries. Once that, it compares with the latest version and computes the deltas. Given the delta, it's formatted and published to Twitter with a delay of 1 minute between tweets.

How I built it

I've built this bot using Python, exactly the version 3.7, using requests for getting the HTML content and BeautifulSoup for parsing the content. For getting this content anonymously and for avoiding getting blocked, I decided to integrate Tor in the scraper. Given the content, it uses the official Python SDK for Twitter for publishing the deltas.

All this project is wrapped up in two Docker containers, using Docker-compose, and deployed in a small virtual machine in the Digital Ocean.

Challenges I ran into

At the very first beginning of this project was kind of difficult to compute the deltas between versions. However, I've discovered the dictdiffer Python library which makes the effort tiny.

Also, the most difficult challenge was, by far, the integration with Tor. It was kind of working locally, running the project as a Python module, but when I decided to move it to Docker decided to not work. Luckily, after some investigation, I was able to configure Tor using Docker and requesting the HTML content anonymously.

Accomplishments that I'm proud of

It's the first time that I've built a Twitter bot and seeing how the Twitter account is getting more and more followers is making me proud of this project.

I know that it's kind of simple, but I'm very happy with the final result.

What I learned

For sure, I learned how to build a Twitter bot since was the first time doing this. Also, I improved my skills in scrapping and understanding how Tor works.

What's next for CoVid19 bot

I think that this bot could improve with a better way of publishing the deltas for avoiding the number of tweets that are being published daily. However, I don't have the correct way to do it (yet).

Share this project: