gkdivya commited on
Commit
834e183
·
1 Parent(s): e8048a6

Update influencer_ui.py

Browse files
Files changed (1) hide show
  1. influencer_ui.py +32 -19
influencer_ui.py CHANGED
@@ -4,13 +4,31 @@ import requests
4
  from io import BytesIO
5
  import json
6
 
 
7
  profile_default_image_url = "https://t4.ftcdn.net/jpg/03/46/93/61/360_F_346936114_RaxE6OQogebgAWTalE1myseY1Hbb5qPM.jpg"
8
  insta_rag_url = "https://us-central1-steam-cache-277314.cloudfunctions.net/gemini-hackathon-insta-influencer"
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
 
10
  def show_influencer_search_page():
11
  st.header("Influencer Search and Analysis")
12
  st.markdown("Discover influencers by name, niche, location, follower count, and more.")
13
  search_query = st.text_input("Search Influencers", "")
 
 
 
14
  search_button = st.button("Search Influencers")
15
 
16
  if search_button:
@@ -19,28 +37,23 @@ def show_influencer_search_page():
19
  response_dict = json.loads(resp.text)
20
 
21
  # Download images
22
- profile_img_url = response_dict.get('profileImageUrl', profile_default_image_url)
23
  img_response = requests.get(profile_img_url)
24
- image_url = profile_default_image_url
25
  if img_response.status_code == 200:
26
  image_url = f"downloaded_image_{response_dict.get('handle', 'NoName')}.jpg"
27
  with open(image_url, "wb") as file:
28
  file.write(img_response.content)
 
 
 
29
 
30
- # Display influencer images and details
31
- col1, col2 = st.columns([1, 3])
32
- with col1:
33
- st.image(image_url, width=50)
34
- with col2:
35
- with st.expander(f"{response_dict.get('name', 'No Name')}'s Details"):
36
- st.markdown(f"**Handle:** {response_dict.get('handle', 'No Handle')}")
37
- st.markdown(f"**Verified:** {'Yes' if response_dict.get('verified', False) else 'No'}")
38
- st.markdown(f"**Platform:** {response_dict.get('platform', 'No Platform')}")
39
- st.markdown(f"**Followers Count:** {response_dict.get('followersCount', 'N/A')}")
40
- st.markdown(f"**Engagement Rate:** {response_dict.get('engagementRate', 'N/A')*100:.2f}%")
41
- st.markdown(f"**Location:** {response_dict.get('contactInfo', {}).get('location', 'N/A')}")
42
- st.markdown(f"**Email:** {response_dict.get('contactInfo', {}).get('email', 'N/A')}")
43
- st.markdown(f"**Country:** {response_dict.get('contactInfo', {}).get('country', 'N/A')}")
44
- st.markdown(f"**Frequent Hashtags:** {response_dict.get('frequentHashtags', 'N/A')}")
45
- st.markdown("### Post Themes")
46
- st.write(response_dict.get('postThemes', 'N/A'))
 
4
  from io import BytesIO
5
  import json
6
 
7
+
8
  profile_default_image_url = "https://t4.ftcdn.net/jpg/03/46/93/61/360_F_346936114_RaxE6OQogebgAWTalE1myseY1Hbb5qPM.jpg"
9
  insta_rag_url = "https://us-central1-steam-cache-277314.cloudfunctions.net/gemini-hackathon-insta-influencer"
10
+ # influencers_data = {
11
+ # "influencer1": {
12
+ # "name": "Influencer One",
13
+ # "image": "./images/inf1.png", # Replace with actual image paths
14
+ # "details": "Details about Influencer One..."
15
+ # },
16
+ # "influencer2": {
17
+ # "name": "Influencer Two",
18
+ # "image": "./images/inf2.png",
19
+ # "details": "Details about Influencer Two..."
20
+ # }
21
+ # # Add more influencers as needed
22
+ # }
23
 
24
+
25
  def show_influencer_search_page():
26
  st.header("Influencer Search and Analysis")
27
  st.markdown("Discover influencers by name, niche, location, follower count, and more.")
28
  search_query = st.text_input("Search Influencers", "")
29
+
30
+
31
+ # Influencer search button (assuming this is part of your UI)
32
  search_button = st.button("Search Influencers")
33
 
34
  if search_button:
 
37
  response_dict = json.loads(resp.text)
38
 
39
  # Download images
40
+ profile_img_url = response_dict.get('profile_image_url', profile_default_image_url)
41
  img_response = requests.get(profile_img_url)
 
42
  if img_response.status_code == 200:
43
  image_url = f"downloaded_image_{response_dict.get('handle', 'NoName')}.jpg"
44
  with open(image_url, "wb") as file:
45
  file.write(img_response.content)
46
+ influencers_data = {response_dict.get('handle', "No Name"): {"name": response_dict.get('name', 'No Name'),
47
+ "image": image_url,
48
+ "details": response_dict.get('bio', '')}}
49
 
50
+ # Display influencer images as clickable buttons
51
+ for influencer_id, influencer_info in influencers_data.items():
52
+ col1, col2 = st.columns([1, 3])
53
+ with col1:
54
+ st.image(influencer_info["image"], width=50)
55
+
56
+ with col2:
57
+ with st.expander("Influencer Details"):
58
+ st.subheader(influencer_info["name"])
59
+ st.write(influencer_info["details"])