File size: 3,154 Bytes
7994ba7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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 psswrd
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")
    # Extract text content (modify the selector based on LinkedIn’s structure)
    text = ' '.join([p.text for p in soup.find_all('p')])
    # Extract emails using regex
    email_pattern = r'[a-zA-Z0-9+._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
    emails = re.findall(email_pattern, text)
    return text, emails