|
import streamlit as st |
|
import requests |
|
import json |
|
import os |
|
|
|
|
|
API_KEY = os.getenv("WHATS_API") |
|
|
|
|
|
API_URL = "https://whatsapp-data.p.rapidapi.com/wspicture" |
|
HEADERS = { |
|
"x-rapidapi-key": API_KEY, |
|
"x-rapidapi-host": "whatsapp-data.p.rapidapi.com" |
|
} |
|
|
|
|
|
st.set_page_config(page_title="WhatsApp Profile Data", layout="wide") |
|
st.title("π± WhatsApp Profile Picture Fetcher") |
|
|
|
|
|
phone_number = st.text_input("Enter Phone Number with Country Code:", "34605797754") |
|
|
|
if st.button("Fetch Data"): |
|
with st.spinner("Fetching profile picture..."): |
|
response = requests.get(API_URL, headers=HEADERS, params={"phone": phone_number}) |
|
|
|
if response.status_code == 200: |
|
data = response.json() |
|
st.success("β
Data Retrieved Successfully!") |
|
|
|
|
|
st.subheader("π JSON Response") |
|
st.json(data) |
|
|
|
|
|
profile_pic = data.get("profile_picture") |
|
if profile_pic: |
|
st.subheader("πΌοΈ Profile Picture URL:") |
|
st.markdown(f"[π View Profile Picture]({profile_pic})") |
|
|
|
|
|
json_data = json.dumps(data, indent=4) |
|
st.subheader("β¬οΈ Download Data") |
|
st.download_button(label="Download JSON", data=json_data, file_name=f"{phone_number}_whatsapp_data.json", mime="application/json") |
|
|
|
else: |
|
st.error("β Failed to retrieve data. Please check the phone number.") |
|
|
|
|
|
st.markdown("---") |
|
st.caption("Powered by RapidAPI & Streamlit") |
|
|