Spaces:
Sleeping
Sleeping
File size: 1,016 Bytes
09321b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import os
class SearchResult:
def __init__(self, title=None, link=None, sniper=None):
assert link or sniper
self.title = title
self.link = link
self.sniper = sniper
class AuthenticationKey:
bing = 'BING_SEARCH_V7_SUBSCRIPTION_KEY'
kuake = 'PLACE_HOLDER'
@classmethod
def to_dict(cls):
raw_dict = cls.__dict__
res = dict(
filter(lambda x: '__' not in x[0] and isinstance(x[1], str),
raw_dict.items()))
return res
def get_websearcher_cls():
def get_env(authentication_key: str):
env = os.environ
return env.get(authentication_key, None)
cls_list = []
if get_env(AuthenticationKey.bing):
from ..web_search_utils.searcher.bing import BingWebSearcher
cls_list.append(BingWebSearcher)
if get_env(AuthenticationKey.kuanke):
from ..web_search_utils.searcher.kuake import KuakeWebSearcher
cls_list.append(KuakeWebSearcher)
return cls_list
|