Spaces:
Build error
Build error
| import requests | |
| import gradio as gr | |
| from bs4 import BeautifulSoup | |
| print('- Finish importing packages') | |
| # Function to search LinkedIn profiles | |
| def search_linkedin_profiles(username, password): | |
| # Initialize session | |
| session = requests.Session() | |
| # Prepare the payload for the POST request | |
| payload = { | |
| "session_key": username, | |
| "session_password": password, | |
| } | |
| # Send the login request | |
| login_submit_url = 'https://www.linkedin.com/checkpoint/lg/login-submit' | |
| response = session.post(login_submit_url, data=payload) | |
| # Check if login was successful | |
| if response.ok: | |
| print('- Finish Task 1: Login to LinkedIn') | |
| return {"response": response.text} # Correctly format the response as a dictionary | |
| else: | |
| return {"error": "Login failed"} # Provide error feedback | |
| # Gradio Interface | |
| iface = gr.Interface( | |
| fn=search_linkedin_profiles, | |
| inputs=[ | |
| gr.Textbox(label="Username", placeholder="Enter your LinkedIn username"), | |
| gr.Textbox(label="Password", placeholder="Enter your LinkedIn password", type="password"), | |
| ], | |
| outputs=gr.JSON(label="Search Result"), # Change the label for clarity | |
| title="LinkedIn", | |
| description="linkedin scraaper test" | |
| ) | |
| # Launch the Gradio app | |
| iface.launch() | |