Guiyom commited on
Commit
0ead65a
·
verified ·
1 Parent(s): 407f9e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -7,7 +7,7 @@ import logging
7
  from typing import Dict, List
8
  from datetime import datetime
9
  from bs4 import BeautifulSoup
10
- from serpapi import GoogleSearch
11
  from newsapi import NewsApiClient
12
 
13
  # Set up logging
@@ -38,13 +38,14 @@ class RaindropSearchBot:
38
  params = {
39
  "q": query,
40
  "num": num_results,
41
- "api_key": self.serpapi_key
 
42
  }
43
- search = GoogleSearch(params)
44
- results = search.get_dict()
45
 
46
  if 'organic_results' in results:
47
- return results['organic_results']
48
  return []
49
 
50
  except Exception as e:
 
7
  from typing import Dict, List
8
  from datetime import datetime
9
  from bs4 import BeautifulSoup
10
+ from serpapi import google_search
11
  from newsapi import NewsApiClient
12
 
13
  # Set up logging
 
38
  params = {
39
  "q": query,
40
  "num": num_results,
41
+ "api_key": self.serpapi_key,
42
+ "engine": "google" # Specify the search engine
43
  }
44
+
45
+ results = google_search(params) # Use the correct function
46
 
47
  if 'organic_results' in results:
48
+ return results['organic_results'][:num_results]
49
  return []
50
 
51
  except Exception as e: