|
@@ -1,10 +1,14 @@
|
|
|
-from .daili66 import Daili66Crawler
|
|
|
-from .ip3366 import IP3366Crawler
|
|
|
-from .iphai import IPHaiCrawler
|
|
|
+import pkgutil
|
|
|
+from .base import BaseCrawler
|
|
|
+import inspect
|
|
|
|
|
|
|
|
|
-__all__ = [
|
|
|
- Daili66Crawler,
|
|
|
- IP3366Crawler,
|
|
|
- IPHaiCrawler
|
|
|
-]
|
|
|
+# load classes subclass of BaseCrawler
|
|
|
+classes = []
|
|
|
+for loader, name, is_pkg in pkgutil.walk_packages(__path__):
|
|
|
+ module = loader.find_module(name).load_module(name)
|
|
|
+ for name, value in inspect.getmembers(module):
|
|
|
+ globals()[name] = value
|
|
|
+ if inspect.isclass(value) and issubclass(value, BaseCrawler) and value is not BaseCrawler:
|
|
|
+ classes.append(value)
|
|
|
+__ALL__ = classes
|