Python Pyaztro – Retrieve daily horoscopes

In this post we will be creating a Python script that will retrieve daily horoscopes, to do this will be using the Pyaztro library which is able to retrieve star sign information and return this in code. Horoscopes look at the positions of moons, stars and planets on the premise that they have influence or can tell us about earthly events.

See the sample of Python code below where we use the Pyaztro library to retrieve daily horoscopes. The script will take a star sign as input from the user and return the relevant horoscope. We have also utilized a try and except block to cater for any input that is not recognised as a valid star sign.

import pyaztro
while True:
    star_sign=input("Please Enter your star sign: ")
    try:
        horoscope = pyaztro.Aztro(sign=star_sign)
        print("Your Daily Horoscrope...")
        print(horoscope.description)
        print("\n")
    except:
        print("Ooops, didnt recognise that star sign... \n")

Some example output for the above can be seen below.

Note – We have written this post for educational purposes only and any horoscopes read do not the represent the views/opinions of Scriptopia.

Please Enter your star sign: Aries
Your Daily Horoscrope...
You can usually decipher any code or solve any puzzle, but you have to admit -- this latest enigmatic communication has you stumped. Go ahead and call the cleverest person you know for their take on things.


Please Enter your star sign: Pisces
Your Daily Horoscrope...
Everyone needs a little bit of private space, and that includes you. Yes, even social creatures like yourself need a place where they can go and decompress. So make your excuses and hightail it there, pronto.
>>>

Take a look at some of our other content around the Python programming language by clicking here.

Leave a Reply