diff --git a/huixiangdou/service/web_search.py b/huixiangdou/service/web_search.py index 0961817..e3f9f1a 100644 --- a/huixiangdou/service/web_search.py +++ b/huixiangdou/service/web_search.py @@ -88,9 +88,16 @@ def __init__(self, config_path: str, retry: int = 1, language:str='zh') -> None: with open(config_path, encoding='utf8') as f: config = pytoml.load(f) self.search_config = types.SimpleNamespace(**config['web_search']) + self.retry = retry self.language = language + def load_key(): + try: + return self.search_config.serper_x_api_key + except Exception as e: + return '' + def fetch_url(self, query: str, target_link: str, brief: str = ''): if not target_link.startswith('http'): return None