CoolFace
Apppublic

shersingh/linkedinextractor

sourceHugging Faceupdated 9d agoView on Hugging Face
0likes
app.py47 linesDownload Raw Back to root
1import streamlit as st
2import requests
3
4st.set_page_config(page_title="LinkedIn Contact Extractor", page_icon="๐Ÿ”", layout="centered")
5st.title("๐Ÿ” LinkedIn Contact Extractor")
6st.write("Enter a LinkedIn profile URL to fetch contact details.")
7
8if "API_KEY" in st.secrets:
9    api_key = st.secrets["API_KEY"]
10else:
11    api_key = st.sidebar.text_input("Enter your API Key", type="password")
12
13profile_url = st.text_input("LinkedIn Profile URL", placeholder="https://linkedin.com")
14
15if st.button("Extract Contact Details"):
16    if not api_key:
17        st.error("Please configure your API Key in Streamlit Secrets or the sidebar.")
18    elif not profile_url:
19        st.error("Please provide a valid LinkedIn Profile URL.")
20    else:
21        with st.spinner("Fetching profile data safely..."):
22            try:
23                api_endpoint = "https://example-provider.com"
24                headers = {"Authorization": f"Bearer {api_key}"}
25                params = {"url": profile_url}
26
27                response = requests.get(api_endpoint, headers=headers, params=params)
28
29                if response.status_code == 200:
30                    data = response.json()
31                    st.success("Data retrieved successfully!")
32
33                    col1, col2 = st.columns(2)
34                    with col1:
35                        st.subheader("๐Ÿ“ง Email")
36                        st.info(data.get("email") or "Not found")
37                    with col2:
38                        st.subheader("๐Ÿ“ž Phone")
39                        st.info(data.get("phone") or "Not found")
40
41                    with st.expander("View Full JSON"):
42                        st.json(data)
43                else:
44                    st.error(f"API Error: {response.status_code}")
45            except Exception as e:
46                st.error(f"Error: {e}")
47