MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / search

Method search

bmtools/tools/bing_search/api.py:47–62  ·  view source on GitHub ↗
(self, key_words : str, max_retry : int = 3)

Source from the content-addressed store, hash-verified

45 self._mkt = 'en-US'
46
47 def search(self, key_words : str, max_retry : int = 3):
48 for _ in range(max_retry):
49 try:
50 result = requests.get(self._endpoint, headers=self._headers, params={'q': key_words, 'mkt': self._mkt }, timeout=10)
51 except Exception:
52 # failed, retry
53 continue
54
55 if result.status_code == 200:
56 result = result.json()
57 # search result returned here
58 return result
59 else:
60 # failed, retry
61 continue
62 raise RuntimeError("Failed to access Bing Search API.")
63
64 def load_page(self, url : str, max_retry : int = 3) -> Tuple[bool, str]:
65 for _ in range(max_retry):

Callers 2

show_outputFunction · 0.45
search_allFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected