If you are a person who believes in horoscopes and also know Python, then this article is for you. Horoscope is a way to forecast future. In this article, I’ll show you how to get your horoscope based on your zodiac sign.
Required Packages
Beautiful soup:
We will use this to extract data out of HTML and can be installed as shown below::
Requests:
We will use this to make HTTP call and can be installed as shown below::
Website For Reading Horoscope
For this article, I’m using a website named https://www.horoscope.com for extracting horoscope information and it looks like this:
From above page, you can select your zodiac sign and select the day. Doing this will generate an URL similar to this: https://www.horoscope.com/us/horoscopes/general/horoscope-general-daily-tomorrow.aspx?sign=9
In this URL, tomorrow represents the day for which I’m looking for horoscope and 9 represents the zodiac sign.
Yes, you guessed it correct. I queried for tomorrow’s data for Sagittarius sign.
Now, in order to fetch the horoscope programmatically, we just need to replace these two values while making a call.
Code To Get Horoscope
Executing above code will the display horoscope for you.
Don't forget to check out the recorded video of this utility on my YouTube channel named Shweta Lodha.
Comments
Post a Comment