SimpleSam commited on
Commit
79ce518
·
verified ·
1 Parent(s): b7b2b80

Update tools/miradi.py

Browse files
Files changed (1) hide show
  1. tools/miradi.py +11 -4
tools/miradi.py CHANGED
@@ -1,9 +1,10 @@
1
  import requests
2
  import urllib.parse
3
 
4
- def duckduckgo_search(query):
5
  """ Search DuckDuckGo using the instant answers API"""
6
-
 
7
  try:
8
  url = "https://api.duckduckgo.com/"
9
  params = {"q": query, "format": "json", "no_redirect": 1, "no_html": 1}
@@ -20,8 +21,14 @@ def duckduckgo_search(query):
20
 
21
  for topic in data.get("RelatedTopics", []):
22
  if "Text" in topic and "FirstURL" in topic:
23
- result.append({
24
- "title":
 
 
25
  })
 
26
  except error:
 
 
 
27
 
 
1
  import requests
2
  import urllib.parse
3
 
4
+ def duckduckgo_search(location, description):
5
  """ Search DuckDuckGo using the instant answers API"""
6
+ query = f"{description} in {location}"
7
+
8
  try:
9
  url = "https://api.duckduckgo.com/"
10
  params = {"q": query, "format": "json", "no_redirect": 1, "no_html": 1}
 
21
 
22
  for topic in data.get("RelatedTopics", []):
23
  if "Text" in topic and "FirstURL" in topic:
24
+ results.append({
25
+ "title": topic.get("Text"),
26
+ "link": topic.get("FirstURL"),
27
+ "snippet": topic.get("Text")
28
  })
29
+ return results
30
  except error:
31
+ print(f"[DuckDuckGo Error] {e}")
32
+ return []
33
+
34