import streamlit as st import time import requests from bs4 import BeautifulSoup from datetime import date import openai import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart import requests import json from groq import Groq import os template = """Shared with you the horoscopes of today, this week, and this month for a couple. Your task is to analyse them provide insights to the couple from all the horoscopes. If you find any event or scenarios mentioned in this month's horoscope and that event is not mentioned in this week's horoscope, consider that as a predicting next week's scenarios. If you find any event or scenarios mentioned in this week's horoscope and that event is not mentioned in today's horoscope, consider that for predicting tommorow's scenarios. Add a section for Today's HoroScope Summary for Husband. Add a section for Today's HoroScope Summary for Wife. Add a section for Couple's HoroScope Insights For This Month. Add a section to aware the couple for any upcoming negative traits or events or scenarios. Add a section to notify about all the Lucky Dates. Add a section for Next Week's Prediction and Tommorow's Prediction. Add a section of Couple Compatibility based on the moon signs of the couple, use your own knowledge and intelligence to deduce it. Use BOLD headlines for all sections using MARKDOWN (**bold**). Use bullets for details for all sections. Add EMOJI for headlines to look interesting. """ def get_daily_pred(url): URL = url headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"} r = requests.get(URL,headers=headers) soup = BeautifulSoup(r.content, 'html.parser') # If this line causes an error, run 'pip install html5lib' or install html5lib #print(soup.prettify()) elements = soup.find_all("div", class_="daily-horo text-center") today=elements[0].text.strip() return(today) def get_monthly_pred(url): URL = url headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"} r = requests.get(URL,headers=headers) soup = BeautifulSoup(r.content, 'html.parser') # If this line causes an error, run 'pip install html5lib' or install html5lib #print(soup.prettify()) article_block =soup.find_all('div', class_="monthly-content") data=[] for articles in article_block: br = articles.find_all('br') for val in br: br_val = val.text.strip() data.append(br_val) monthly = ' '.join(map(str, data)) mday=article_block[0].text.strip() return(mday) def get_weekly_pred(url): URL = url headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"} r = requests.get(URL,headers=headers) soup = BeautifulSoup(r.content, 'html.parser') # If this line causes an error, run 'pip install html5lib' or install html5lib #print(soup.prettify()) article_block =soup.find_all('div', class_="daily-horo text-center") data=[] for articles in article_block: br = articles.find_all('br') for val in br: br_val = val.text.strip() data.append(br_val) weekly = ' '.join(map(str, data)) wday=article_block[0].text.strip() return(wday) def predict_horoscope(m_sign, f_sign,strtime,m_daily_pred,f_daily_pred,m_monthly_pred,f_monthly_pred,m_weekly_pred,f_weekly_pred): # Add your horoscope prediction logic here client = Groq() client = Groq(api_key = os.getenv("GROQ_API_KEY")) chatresponse = client.chat.completions.create( model="deepseek-r1-distill-llama-70b", messages=[ {"role": "system", "content": "You are a Horoscope Analyser. Think step by step. Answer in details with professional and dramatic tone"}, {"role": "user", "content": template}, {"role": "user", "content": "Today's date is: " + strtime}, {"role": "user", "content": "Husband's Moon Sign: " + m_sign}, {"role": "user", "content": "Wife's Moon Sign: " + f_sign}, {"role": "user", "content": "Husband Daily Horoscope: " + m_daily_pred}, {"role": "user", "content": "Husband Weekly Horoscope: " + m_weekly_pred}, {"role": "user", "content": "Husband Monthly Horoscope: " + m_monthly_pred}, {"role": "user", "content": "Wife Daily Horoscope: " + f_daily_pred}, {"role": "user", "content": "Wife Weekly Horoscope: " + f_weekly_pred}, {"role": "user", "content": "Wife Monthly Horoscope: " + f_monthly_pred} ], temperature=0.6, stop=None, stream=False ) time.sleep(1) prediction = chatresponse.choices[0].message.content return prediction def send_email(email,msg,stdate): # Your Gmail credentials sender_email = "einsteingptai@gmail.com" sender_password = "ibxccfsdcyzeittm" # Recipient email address receiver_email = email message = MIMEMultipart("alternative") message["Subject"] = "Horoscope Insights of " + stdate message["From"] = sender_email message["To"] = receiver_email text = msg part1 = MIMEText(text, "plain") message.attach(part1) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender_email, sender_password) server.sendmail(sender_email, receiver_email, message.as_string()) server.quit() st.success("Email sent successfully!") #yagmail def send_yagmail(email,msg,stdate): import yagmail #receiver = email #body = "Hello there from Yagmail HF" #filename = "document.pdf" sender_email = "einsteingptai@gmail.com" sender_password = "ibxccfsdcyzeittm" yag = yagmail.SMTP(sender_email,sender_password) yag.send( to=email, subject="Horoscope Insights of " + stdate, contents=msg #attachments=filename, ) st.success("Yagmail sent successfully!") def send_brevomail(email,msg,stdate): url = 'https://api.brevo.com/v3/smtp/email' headers = { 'accept': 'application/json', 'api-key': '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', 'content-type': 'application/json' } sender_email = "einsteingptai@gmail.com" receiver_email = email subject = "Your Horoscope for " + stdate body = "

Hello, here is your today's hororscope in short...

"+msg+"

" data = { "sender": { "name": "Einstein AI", "email": sender_email }, "to": [ { "email": receiver_email } ], "subject": subject, "htmlContent": body } try: response = requests.post(url, headers=headers, data=json.dumps(data)) if response.status_code == 200: st.success("Email sent successfully!") #print(response.text) else: st.error(f"Error {response.status_code}: {response.text}") except requests.exceptions.HTTPError as errh: st.error(f"HTTP Error: {errh}") except requests.exceptions.ConnectionError as errc: st.error(f"Error Connecting: {errc}") except requests.exceptions.Timeout as errt: st.error(f"Timeout Error: {errt}") except requests.exceptions.RequestException as err: st.error(f"An unexpected error occurred: {err}") def main(): st.set_page_config( page_title="Horoscope Insights", page_icon="♏", layout="wide" ) st.title("Couple's Horoscope Insights") st.markdown('Based on **Moon Signs** and **Vedic Astrology**. Get your Moon Sign from [here](https://instaastro.com/vedic-astrology/moon-sign-calculator/)') signs = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"] col1, col2 = st.columns(2) # Create two columns with col1: male_sign = st.selectbox("Choose Husband's Moon Sign", signs) with col2: female_sign = st.selectbox("Choose Wife's Moon Sign", signs) m_sign= male_sign f_sign= female_sign m_url_daily="https://www.indastro.com/horoscope/"+m_sign+"-daily-horoscope.html" f_url_daily="https://www.indastro.com/horoscope/"+f_sign+"-daily-horoscope.html" m_url_monthly="https://www.indastro.com/horoscope/"+m_sign+"-monthly-horoscope.html" f_url_monthly="https://www.indastro.com/horoscope/"+f_sign+"-monthly-horoscope.html" m_url_weekly="https://www.indastro.com/horoscope/weekly-horoscope/"+m_sign+".html" f_url_weekly="https://www.indastro.com/horoscope/weekly-horoscope/"+f_sign+".html" m_daily_pred = get_daily_pred(m_url_daily) f_daily_pred = get_daily_pred(f_url_daily) m_monthly_pred = get_monthly_pred(m_url_monthly) f_monthly_pred = get_monthly_pred(f_url_monthly) m_weekly_pred = get_weekly_pred(m_url_weekly) f_weekly_pred = get_weekly_pred(f_url_weekly) today = date.today() strtime = today.strftime("%d-%B-%Y") pred = [] if st.button("Show Insights"): with st.spinner("Generating Insights..."): prediction = predict_horoscope(m_sign, f_sign,strtime,m_daily_pred,f_daily_pred,m_monthly_pred,f_monthly_pred,m_weekly_pred,f_weekly_pred) st.info("**Today's is**: " + strtime + " | **Husband's Moon Sign**: " + m_sign + " | **Wife's Moon Sign**: " + f_sign) title = "Today's is: " + strtime + " | Husband's Moon Sign: " + m_sign + " | Wife's Moon Sign: " + f_sign #st.success("Insight generated!") pred.append(prediction) st.markdown(prediction) #st.text(prediction) email = st.text_input("Enter email address", "") if st.button("Send Email"): remail=email.strip() msg = ' '.join(map(str, pred)) if msg == '' : st.error("Message Body is Null") else: send_brevomail(remail,msg,strtime) time.sleep(2) st.success("Have a Great Day !") if __name__ == '__main__': main()