|
|
import smtplib |
|
|
from email.mime.multipart import MIMEMultipart |
|
|
from email.mime.text import MIMEText |
|
|
from email.mime.base import MIMEBase |
|
|
from email import encoders |
|
|
import os |
|
|
import pandas as pd |
|
|
import smtplib |
|
|
from email.mime.multipart import MIMEMultipart |
|
|
from email.mime.text import MIMEText |
|
|
from email.mime.base import MIMEBase |
|
|
from email import encoders |
|
|
import time |
|
|
|
|
|
import groq |
|
|
import os |
|
|
import re |
|
|
import requests |
|
|
from bs4 import BeautifulSoup |
|
|
|
|
|
|
|
|
GROQ_API_KEY = os.getenv("GROQ_API_KEY") |
|
|
Groq = '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' |
|
|
client = groq.Client(api_key=Groq) |
|
|
from_email = "03117711721_iot@vips.edu" |
|
|
password ="ehdj jdgo awjc fcko" |
|
|
server = smtplib.SMTP("smtp.gmail.com", 587) |
|
|
server.starttls() |
|
|
server.login(from_email, password) |
|
|
|
|
|
def is_valid_email(email): |
|
|
import re |
|
|
email_regex = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$' |
|
|
return re.match(email_regex, email) is not None |
|
|
|
|
|
def format_email_body(text): |
|
|
return f"Dear Recipient,\n\n{text}\n\nBest Regards,\nVaibhav Wadhwa" |
|
|
|
|
|
def Body(text): |
|
|
f=str() |
|
|
op = client.chat.completions.create( |
|
|
model="llama-3.3-70b-versatile", |
|
|
messages=[{ |
|
|
"role": "system", |
|
|
"content": f"{res}" |
|
|
}, |
|
|
{ |
|
|
"role": "user", |
|
|
"content": f"Write a mail to hr based on {text} research about there company and show them how I can be an asset to their company and talk about my accomplishments and experience. Just the body no Preamble." |
|
|
}], |
|
|
temperature=0.83, |
|
|
max_completion_tokens=730, |
|
|
top_p=1, |
|
|
stream=True, |
|
|
stop=None |
|
|
) |
|
|
for chunk in op: |
|
|
f+=f'{chunk.choices[0].delta.content}' |
|
|
|
|
|
return f |
|
|
|
|
|
def Subject(text): |
|
|
f=str() |
|
|
op = client.chat.completions.create( |
|
|
model="llama-3.3-70b-versatile", |
|
|
messages=[{ |
|
|
"role": "system", |
|
|
"content": f"{res}" |
|
|
}, |
|
|
{ |
|
|
"role": "user", |
|
|
"content": f"Write a mail to hr based on {text} research about there company and show them how I can be an asset to their company and talk about my accomplishments and experience. and use my given data Just the Subject no Preamble." |
|
|
}], |
|
|
temperature=1.1, |
|
|
max_completion_tokens=730, |
|
|
top_p=1, |
|
|
stream=True, |
|
|
stop=None |
|
|
) |
|
|
for chunk in op: |
|
|
f+=f'{chunk.choices[0].delta.content}' |
|
|
|
|
|
return f |
|
|
|
|
|
|
|
|
def extract_text_and_emails_from_linkedin(url): |
|
|
headers = { |
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" |
|
|
} |
|
|
response = requests.get(url, headers=headers) |
|
|
if response.status_code != 200: |
|
|
return "Failed to fetch the post", [] |
|
|
soup = BeautifulSoup(response.text, "html.parser") |
|
|
|
|
|
text = ' '.join([p.text for p in soup.find_all('p')]) |
|
|
|
|
|
email_pattern = r'[a-zA-Z0-9+._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' |
|
|
emails = re.findall(email_pattern, text) |
|
|
return text, emails |