|
| 1 | +from bs4 import BeautifulSoup |
| 2 | +import requests |
| 3 | + |
| 4 | +""" |
| 5 | + this check_sign function checks and returns the zodiac sign |
| 6 | + by day and month of your birth |
| 7 | +
|
| 8 | +""" |
| 9 | + |
| 10 | + |
| 11 | +def check_sign(): |
| 12 | + your_birth_day = input("enter your birthday day number> ") |
| 13 | + your_birth_month = input("cool, and the month number, please> ") |
| 14 | + if (int(your_birth_month) == 12 and int(your_birth_day) >= 22) or ( |
| 15 | + int(your_birth_month) == 1 and int(your_birth_day) <= 19 |
| 16 | + ): |
| 17 | + sign = "Capricorn" |
| 18 | + elif (int(your_birth_month) == 1 and int(your_birth_day) >= 20) or ( |
| 19 | + int(your_birth_month) == 2 and int(your_birth_day) <= 17 |
| 20 | + ): |
| 21 | + sign = "Aquarium" |
| 22 | + elif (int(your_birth_month) == 2 and int(your_birth_day) >= 18) or ( |
| 23 | + int(your_birth_month) == 3 and int(your_birth_day) <= 19 |
| 24 | + ): |
| 25 | + sign = "Pices" |
| 26 | + elif (int(your_birth_month) == 3 and int(your_birth_day) >= 20) or ( |
| 27 | + int(your_birth_month) == 4 and int(your_birth_day) <= 19 |
| 28 | + ): |
| 29 | + sign = "Aries" |
| 30 | + elif (int(your_birth_month) == 4 and int(your_birth_day) >= 20) or ( |
| 31 | + int(your_birth_month) == 5 and int(your_birth_day) <= 20 |
| 32 | + ): |
| 33 | + sign = "Taurus" |
| 34 | + elif (int(your_birth_month) == 5 and int(your_birth_day) >= 21) or ( |
| 35 | + int(your_birth_month) == 6 and int(your_birth_day) <= 20 |
| 36 | + ): |
| 37 | + sign = "Gemini" |
| 38 | + elif (int(your_birth_month) == 6 and int(your_birth_day) >= 21) or ( |
| 39 | + int(your_birth_month) == 7 and int(your_birth_day) <= 22 |
| 40 | + ): |
| 41 | + sign = "Cancer" |
| 42 | + elif (int(your_birth_month) == 7 and int(your_birth_day) >= 23) or ( |
| 43 | + int(your_birth_month) == 8 and int(your_birth_day) <= 22 |
| 44 | + ): |
| 45 | + sign = "Leo" |
| 46 | + elif (int(your_birth_month) == 8 and int(your_birth_day) >= 23) or ( |
| 47 | + int(your_birth_month) == 9 and int(your_birth_day) <= 22 |
| 48 | + ): |
| 49 | + sign = "Virgo" |
| 50 | + elif (int(your_birth_month) == 9 and int(your_birth_day) >= 23) or ( |
| 51 | + int(your_birth_month) == 10 and int(your_birth_day) <= 22 |
| 52 | + ): |
| 53 | + sign = "Libra" |
| 54 | + elif (int(your_birth_month) == 10 and int(your_birth_day) >= 23) or ( |
| 55 | + int(your_birth_month) == 11 and int(your_birth_day) <= 21 |
| 56 | + ): |
| 57 | + sign = "Scorpio" |
| 58 | + elif (int(your_birth_month) == 11 and int(your_birth_day) >= 22) or ( |
| 59 | + int(your_birth_month) == 12 and int(your_birth_day) <= 21 |
| 60 | + ): |
| 61 | + sign = "Sagittarius" |
| 62 | + |
| 63 | + return sign |
| 64 | + |
| 65 | + |
| 66 | +def horoscope(zodiac_sign: int, day: str) -> str: |
| 67 | + url = ( |
| 68 | + "https://www.horoscope.com/us/horoscopes/general/" |
| 69 | + f"horoscope-general-daily-{day}.aspx?sign={zodiac_sign}" |
| 70 | + ) |
| 71 | + soup = BeautifulSoup(requests.get(url).content, "html.parser") |
| 72 | + return soup.find("div", class_="main-horoscope").p.text |
| 73 | + |
| 74 | + |
| 75 | +if __name__ == "__main__": |
| 76 | + print("Daily Horoscope. \n") |
| 77 | + print( |
| 78 | + "enter your Zodiac sign number:\n", |
| 79 | + "1. Aries\n", |
| 80 | + "2. Taurus\n", |
| 81 | + "3. Gemini\n", |
| 82 | + "4. Cancer\n", |
| 83 | + "5. Leo\n", |
| 84 | + "6. Virgo\n", |
| 85 | + "7. Libra\n", |
| 86 | + "8. Scorpio\n", |
| 87 | + "9. Sagittarius\n", |
| 88 | + "10. Capricorn\n", |
| 89 | + "11. Aquarius\n", |
| 90 | + "12. Pisces\n", |
| 91 | + "\nor if you're not sure about you sign, type 'calculate'", |
| 92 | + ) |
| 93 | + zodiac_sign = input("number> ") |
| 94 | + if zodiac_sign != "calculate": |
| 95 | + print("choose some day:\n", "yesterday\n", "today\n", "tomorrow\n") |
| 96 | + day = input("enter the day> ") |
| 97 | + horoscope_text = horoscope(zodiac_sign, day) |
| 98 | + print(horoscope_text) |
| 99 | + else: |
| 100 | + print("\nOk, don't worry. Soon you'll get it just pass this tiny quiz") |
| 101 | + print("\nCongratulations! you are defenetly", check_sign()) |
0 commit comments