Satyam0077 commited on
Commit
6497e33
·
verified ·
1 Parent(s): 27dbcc3

Update search.py

Browse files
Files changed (1) hide show
  1. search.py +4 -4
search.py CHANGED
@@ -3,16 +3,17 @@ import pandas as pd
3
  import time
4
  import os
5
 
6
- # ✅ Safely get the API key from the environment or fallback to empty string
7
- API_KEY = os.getenv("3696a83abc995ae3bb2f392fd9b899d721e7b35b8b29f80cb0bd7b62c55fe132", "")
8
 
9
- # ✅ Ensure API_KEY is available
10
  if not API_KEY:
11
  raise ValueError("API key is missing. Please set the SERPAPI_API_KEY environment variable.")
12
 
13
  def get_collaboration_data(competitors, target="Virgin Media"):
14
  results = []
15
 
 
16
  for comp in competitors:
17
  query = f"{comp} {target} partnership OR collaboration"
18
  params = {
@@ -48,4 +49,3 @@ def get_collaboration_data(competitors, target="Virgin Media"):
48
 
49
  # Return results as a DataFrame
50
  return pd.DataFrame(results)
51
-
 
3
  import time
4
  import os
5
 
6
+ # ✅ Retrieve the API key from Hugging Face secrets
7
+ API_KEY = os.getenv("SERPAPI_API_KEY", "") # This will get the API key from Hugging Face secrets
8
 
9
+ # ✅ Check if the API_KEY is set
10
  if not API_KEY:
11
  raise ValueError("API key is missing. Please set the SERPAPI_API_KEY environment variable.")
12
 
13
  def get_collaboration_data(competitors, target="Virgin Media"):
14
  results = []
15
 
16
+ # Iterate over each competitor to search for collaborations with Virgin Media
17
  for comp in competitors:
18
  query = f"{comp} {target} partnership OR collaboration"
19
  params = {
 
49
 
50
  # Return results as a DataFrame
51
  return pd.DataFrame(results)