Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,40 +3,38 @@ import gradio as gr
|
|
3 |
from playwright.sync_api import sync_playwright
|
4 |
from bs4 import BeautifulSoup
|
5 |
|
6 |
-
import
|
7 |
-
from
|
8 |
-
|
9 |
-
# Ensure Playwright browsers are installed before using them
|
10 |
-
os.system("playwright install --with-deps")
|
11 |
|
12 |
def scrape_profile(url):
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Gradio UI
|
26 |
-
import gradio as gr
|
27 |
-
|
28 |
-
def fetch_profile(url):
|
29 |
-
data = scrape_profile(url)
|
30 |
-
return f"Name: {data['Name']}\nSummary: {data['Summary']}"
|
31 |
-
|
32 |
iface = gr.Interface(
|
33 |
-
fn=
|
34 |
inputs=gr.Textbox(label="Enter LinkedIn Profile URL"),
|
35 |
outputs=gr.Textbox(label="Profile Data"),
|
36 |
live=True
|
37 |
)
|
38 |
|
39 |
iface.launch()
|
|
|
40 |
|
41 |
|
42 |
|
|
|
3 |
from playwright.sync_api import sync_playwright
|
4 |
from bs4 import BeautifulSoup
|
5 |
|
6 |
+
import requests
|
7 |
+
from bs4 import BeautifulSoup
|
8 |
+
import gradio as gr
|
|
|
|
|
9 |
|
10 |
def scrape_profile(url):
|
11 |
+
headers = {
|
12 |
+
"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"
|
13 |
+
}
|
14 |
+
|
15 |
+
response = requests.get(url, headers=headers)
|
16 |
+
|
17 |
+
if response.status_code != 200:
|
18 |
+
return "Failed to retrieve profile. Ensure the URL is correct and accessible."
|
19 |
+
|
20 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
21 |
+
|
22 |
+
# Extract profile details (Modify selectors as needed)
|
23 |
+
name = soup.find("h1").text.strip() if soup.find("h1") else "Name not found"
|
24 |
+
summary = soup.find("p").text.strip() if soup.find("p") else "Summary not found"
|
25 |
+
|
26 |
+
return f"Name: {name}\nSummary: {summary}"
|
27 |
|
28 |
# Gradio UI
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
iface = gr.Interface(
|
30 |
+
fn=scrape_profile,
|
31 |
inputs=gr.Textbox(label="Enter LinkedIn Profile URL"),
|
32 |
outputs=gr.Textbox(label="Profile Data"),
|
33 |
live=True
|
34 |
)
|
35 |
|
36 |
iface.launch()
|
37 |
+
|
38 |
|
39 |
|
40 |
|