Spaces:
Configuration error
Configuration error
File size: 1,874 Bytes
a166886 | 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 | import streamlit as st
import requests
st.set_page_config(page_title="LinkedIn Contact Extractor", page_icon="π", layout="centered")
st.title("π LinkedIn Contact Extractor")
st.write("Enter a LinkedIn profile URL to fetch contact details.")
if "API_KEY" in st.secrets:
api_key = st.secrets["API_KEY"]
else:
api_key = st.sidebar.text_input("Enter your API Key", type="password")
profile_url = st.text_input("LinkedIn Profile URL", placeholder="https://linkedin.com")
if st.button("Extract Contact Details"):
if not api_key:
st.error("Please configure your API Key in Streamlit Secrets or the sidebar.")
elif not profile_url:
st.error("Please provide a valid LinkedIn Profile URL.")
else:
with st.spinner("Fetching profile data safely..."):
try:
api_endpoint = "https://example-provider.com"
headers = {"Authorization": f"Bearer {api_key}"}
params = {"url": profile_url}
response = requests.get(api_endpoint, headers=headers, params=params)
if response.status_code == 200:
data = response.json()
st.success("Data retrieved successfully!")
col1, col2 = st.columns(2)
with col1:
st.subheader("π§ Email")
st.info(data.get("email") or "Not found")
with col2:
st.subheader("π Phone")
st.info(data.get("phone") or "Not found")
with st.expander("View Full JSON"):
st.json(data)
else:
st.error(f"API Error: {response.status_code}")
except Exception as e:
st.error(f"Error: {e}")
|