From be2e0435840ef79e7d7c52b84f05068ba40ea7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=9A=E9=A3=8E=E6=8B=82=E6=9F=B3=E9=A2=9C?= <434857005@qq.com> Date: Wed, 10 Jan 2024 03:01:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9py=E6=A0=87=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- txt/hipy/cctv_spider.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/txt/hipy/cctv_spider.py b/txt/hipy/cctv_spider.py index 95d0d2a..3271902 100644 --- a/txt/hipy/cctv_spider.py +++ b/txt/hipy/cctv_spider.py @@ -213,21 +213,25 @@ class Spider(BaseSpider): # 元类 默认的元类 type except Exception as e: print(f'更新扩展筛选条件发生错误:{e}') - print("============{0}============".format(extend)) - if isinstance(extend, str): - if extend.startswith('./'): - ext_file = os.path.join(os.path.dirname(__file__), extend) + print("============依赖列表:{0}============".format(extend)) + ext = self.extend + print("============ext:{0}============".format(ext)) + if isinstance(ext, str) and ext: + if ext.startswith('./'): + ext_file = os.path.join(os.path.dirname(__file__), ext) init_file(ext_file) - elif extend.startswith('http'): + elif ext.startswith('http'): try: - r = self.fetch(extend) + r = self.fetch(ext) self.config['filter'].update(r.json()) except Exception as e: print(f'更新扩展筛选条件发生错误:{e}') - elif extend and not extend.startswith('./') and not extend.startswith('http'): - ext_file = os.path.join(os.path.dirname(__file__), './' + extend + '.json') + elif not ext.startswith('./') and not ext.startswith('http'): + ext_file = os.path.join(os.path.dirname(__file__), './' + ext + '.json') init_file(ext_file) - elif isinstance(extend, list): + + # 装载模块,这里只要一个就够了 + if isinstance(extend, list): for lib in extend: if '.Spider' in str(type(lib)): self.module = lib