import gradio as gr from playwright.sync_api import sync_playwright from bs4 import BeautifulSoup import requests from bs4 import BeautifulSoup import gradio as gr def scrape_profile(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 retrieve profile. Ensure the URL is correct and accessible." soup = BeautifulSoup(response.text, "html.parser") # Extract profile details (Modify selectors as needed) name = soup.find("h1").text.strip() if soup.find("h1") else "Name not found" summary = soup.find("p").text.strip() if soup.find("p") else "Summary not found" return f"Name: {name}\nSummary: {summary}" # Gradio UI iface = gr.Interface( fn=scrape_profile, inputs=gr.Textbox(label="Enter LinkedIn Profile URL"), outputs=gr.Textbox(label="Profile Data"), live=True ) iface.launch() # def home(): # return "Welcome, Name!\nHeadline: [Your Headline]\nLocation: [Your Location]\nIndustry: [Your Industry]\nSummary: [Your Summary]\nExperience: [Your Experience]\nEducation: [Your Education]" # def interests(): # return "Suggested Areas of Interest:\n☑ AI\n☑ FinTech\n☑ Software Engineering\n[Express in Natural Language]" # def networking(): # return "People to Follow:\n- Person 1\n- Person 2\nPeople to Connect:\n- Person 3\n- Person 4\nPosts to Read:\n- Post 1\n- Post 2" # def jobs(): # return "Set Job Goals: [Your Job Goals]\nJobs to Apply:\n- Job 1\n- Job 2\nRecruiters to Connect:\n- Recruiter 1\n- Recruiter 2\nCourses to Learn:\n- Course 1\n- Course 2" # # Gradio UI # with gr.Blocks() as demo: # gr.Markdown("## Enter a LinkedIn Profile URL to Extract Data") # url_input = gr.Textbox(label="LinkedIn Profile URL", placeholder="https://www.linkedin.com/in/username/") # output_box = gr.Textbox(label="Extracted Profile Data") # submit_btn = gr.Button("Submit") # submit_btn.click(scrape_profile, inputs=url_input, outputs=output_box) # demo.launch()