DogeCoin Price Notifier with web scraping and WhatsApp notification

Nilay Chauhan
Data Stash
Published in
2 min readMay 7, 2021

After the tweet of Elon Musk, the price of Dogecoin has gone up significantly over the past month or so. It has been trending a lot. The Dogecoin price has skyrocketed from $0.05 to an all-time high of $0.6 today. I wanted to buy a dogecoin in order to invest some of my savings. But guess what? But with raise of prices, it was impossible to get it at a reasonable price.

The Project

The aim of this project is to create a tool that will make a survey on the price of the dogecoin from coinmarketcap, check if the price is lower than a specific threshold, and receive a whatsapp notification if yes with the price and then will set a corn job to run this script at a fixed interval using AWS lightsail.

Install and import Libraries

  • Requests: It is a python library which allows you to send HTTP requests.
  • BeautifulSoup: It is a python library for pulling data out of various data formats such as HTML and XML files.
  • Twilio: It is an API which we will be using to get price notifications on whatsapp.
!pip install twilio
!pip install beautifulsoup4

import numpy as np
import pandas as pd
from bs4 import BeautifulSoup
import requests
import json
import time
from twilio.rest import Client

Scraping Dogecoin price

First, we will get the make a HTTP request to coinmarketcap using the requests library, and then we will use BeautifulSoup library to pull data from that requests using HTML parser.

url='https://coinmarketcap.com/currencies/dogecoin/'
coin_market = requests.get(url)
soup = BeautifulSoup(coin_market.content, 'html.parser')

Now, we have the entire HTML data of the website in the variable called soup, and we have to find the dogecoin price from this data for which we will be using find method of beautifulsoup library and then we will convert it to float so we can compare it with the tracking price/ threshold we have set.

price = soup.find("div",{"class":"priceValue___11gHJ"}).get_text().replace("$","").replace(",","").strip()
price_float = float(price)

Getting price notification on whatsapp

For Getting price notification on whatsapp, we will be using twilio, which provides services to send whatsapp messages using their API services. It provides a whatsapp number linked with specific ID and API key which allows us to set up the message.

account_sid = 'YOUR_TWILIO_ACCOUNT_ID' 
auth_token = 'YOUR_TWILIO_AUTHTOKEN'
client = Client(account_sid, auth_token)

message = client.messages.create(
from_='whatsapp:TWILIO_WHATSAPP_NUMBER',
body=price_list,
to='whatsapp:YOUR_WHATSAPP_NUMBER'
)
print(message.sid)

I have uploaded a kernel on Kaggle where I have uploaded the complete script, please visit here

Automate script with AWS Lightsail

Follow this steps to automate this script and set up corn job:

  • First create an AWS Lightsail ubuntu instance.
  • Install Python3.7 and pip on your ubuntu instance.
  • Clone your python repository to the instance.
  • Create a cron job that will run every hour.

For complete tutorial on how to automate scripts using AWS Lightsail, please refer this blog.

--

--