Simple python script to fetch the equivalent price of 1 Dogecoin in the local currency
For the last few days, Dogecoin has been a much-hyped thing over the internet. I wrote a simple python script that scraps the price of 1 Dogecoin in INR (as I am from India) from a website (Yahoo Finance) and sends me as an alert to my personal WhatsApp.
So, I went to this website: https://in.finance.yahoo.com/quote/DOGE-INR/, as you can see here in the image below.

So you can see that, I have highlighted the value of 1 Dogecoin shown there, using a brown-colored rectangle. Now, I need to scrap this value out of this page. I wrote a python script to do that. I will discuss each line of code step by step.

In the above code, which you can see, I am using a Python library called lxml. To extract/scrape the value of 1 Dogecoin from the website, I decided to take the route of directly fetching the text value from the XPath of whichever element on this page contains the same. lxml serves the purpose for that job. requests is another library in python which is needed to make HTTP requests. I will explain the use of this two shortly.

In the above code snippet, I specified the URL from which we will scrap our data.

As you can see, I am hitting a GET request to the same page.

I parse the entire content into a string.

As you can see, in the above snippet, I fetched the value from the element by specifying its XPath.

In the above snippet, I made a post request to a bot (CallMeBot API) to send me the value of 1 Dogecoin personally on WhatsApp. For more information on how to set up everything and use their API, please refer to their website: https://www.callmebot.com/.
By running this script, you will get a notification on your personal WhatsApp from this bot. I wanted my Windows machine to run this script automatically at an interval of 6 hrs. a day so that I get notified automatically when I am working on something else. So, I created a bat script for that which will run this python script. After that, I created a task in the task scheduler, which will run this bat script at an interval of 6 hrs. a day.
Though it is a small script, I wanted to share with you guys, especially those who are absolute beginners, how to do these kinds of small automation, by using Python.
That’s all for this article. Thank you, everyone, for taking your time out to read the same.