MCPcopy
hub / github.com/stitionai/devika / BingSearch

Class BingSearch

src/browser/search.py:10–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class BingSearch:
11 def __init__(self):
12 self.config = Config()
13 self.bing_api_key = self.config.get_bing_api_key()
14 self.bing_api_endpoint = self.config.get_bing_api_endpoint()
15 self.query_result = None
16
17 def search(self, query):
18 headers = {"Ocp-Apim-Subscription-Key": self.bing_api_key}
19 params = {"q": query, "mkt": "en-US"}
20
21 try:
22 response = requests.get(self.bing_api_endpoint, headers=headers, params=params)
23 response.raise_for_status()
24 self.query_result = response.json()
25 return self.query_result
26 except Exception as error:
27 return error
28
29 def get_first_link(self):
30 return self.query_result["webPages"]["value"][0]["url"]
31
32
33class GoogleSearch:

Callers 2

search_queriesMethod · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected