Created
October 13, 2021 09:25
-
-
Save akkuman/7cb5db45261d76f7ba1c46fe90178e44 to your computer and use it in GitHub Desktop.
[获取scrapy所有spider name] #python #scrapy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scrapy import spiderloader | |
from scrapy.utils import project | |
def get_all_spider_names() -> typing.List[str]: | |
os.environ.setdefault('SCRAPY_SETTINGS_MODULE', 'darkweb.settings') | |
settings = project.get_project_settings() | |
spider_loader = spiderloader.SpiderLoader.from_settings(settings) | |
return spider_loader.list() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment