gpt4 book ai didi

scrapy - 如何将我的蜘蛛组织到Scrapy中的嵌套目录中?

转载 作者:行者123 更新时间:2023-12-04 14:41:24 32 4
gpt4 key购买 nike

我有以下目录结构:

my_project/
__init__.py
spiders/
__init__.py
my_spider.py
other_spider.py
pipeines.py
# other files

现在,我可以进入 my_project目录,并使用 scrapy crawl my_spider开始抓取。

我想要实现的是能够使用此更新的结构运行 scrapy crawl my_spider:
my_project/
__init__.py
spiders/
__init__.py
subtopic1/
__init__.py # <-- I get the same error whether this is present or not
my_spider.py
subtopicx/
other_spider.py
pipeines.py
# other files

但是现在我得到这个错误:

KeyError: 'Spider not found: my_spider'



将Scrapy蜘蛛组织到目录中的合适方法是什么?

最佳答案

您必须从包含 scrapy.cfg 的目录中运行此scrapy crawl my_spider。您不会收到任何错误。

my_project/
__init__.py
spiders/
__init__.py
my_spider.py
sub_directory
__init__.py
other_spider.py
pipeines.py
scrapy.cfg

关于scrapy - 如何将我的蜘蛛组织到Scrapy中的嵌套目录中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37915502/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com