Code Monkey home page Code Monkey logo

covid-19-sms-notifier's Introduction

COVID-19-SMS-Notifier

US COVID-19 Map Credit: Pharexia / CC BY-SA

Demonstration of rapid development using python by a total novice. This application scrapes NC Department of Public Health COVID-19 data. Every 6 hours AWS cloudwatch triggers an AWS lambda function that sends the update as SMS via Twilio.

Building Blocks:

  1. Twilio account with SMS number (alternative AWS SMS)
  2. AWS account
  3. Python (3.7)

Data Source:

First, be responsible! Don't hammer the NC Department of Public Health Website. I am only querying every 6 hours. If they had an api, it would be a little easier. CDC currently (3/29/2020) doesn't have an api either. Not sure why.

Set-up

The lambda function is pretty straight forward. It is just a .py file. The tricky part (for me) was the dependencies. AWS lambda has layers (up to 5). You create a requirement.txt file and pip install to grab all the dependencies. You then zip up the dependencies and load them into a lambda layer. The file structure for the zip file matters. Also, the permissions for the zip file matters.

The program starts as a lambda function and scrapes the NC website using beautifulsoup. A little parsing is done and it is good to go. Since we are running off a lightweight lambda function, you can't lookup/store historical data (of course, you could write to a dynamoDB or S3 and query it...I just didn't have time).

The data is then sent out as SMS using Twilio SMS api. You will need your own credientials.

Using a cloudwatch event, the lambda is called every 6 hours. I don't currently know how quickly NC will update the data. Also, the website layout was changed overnight and required me to quickly tweak the scraping (NC -- please don't change the layout OR provide an API -- please).

Comments

  • This could easily be expanded to other counties, states, or countries.
  • This could easily be developed into an aggregator of multiple data sources.
  • Since the data is not changing that quickly, please don't query the NC website excessively.
  • The lambda function is not expensive. However, the current set-up uses twilio sms. This can add-up and certainly other services or APIs can be built to lower the cost.

Worth Mentioning

Thank You

covid-19-sms-notifier's People

Contributors

clancyclark avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.