Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7578279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:23:40+00:00 2026-05-30T17:23:40+00:00

The docs says i could only execute the crawl command inside the project dir

  • 0

The docs says i could only execute the crawl command inside the project dir :

scrapy crawl tutor -o items.json -t json

but i really need to execute it in my python code (the python file is not inside current project dir)

Is there any approach fit my requirement ?

My project tree:

.
├── etao
│   ├── etao
│   │   ├── __init__.py
│   │   ├── items.py
│   │   ├── pipelines.py
│   │   ├── settings.py
│   │   └── spiders
│   │       ├── __init__.py
│   │       ├── etao_spider.py
│   ├── items.json
│   ├── scrapy.cfg
│   └── start.py
└── start.py    <-------------- I want to execute the script here.

Any here’s my code followed this link but it doesn’t work:

#!/usr/bin/env python
import os
#Must be at the top before other imports
os.environ.setdefault('SCRAPY_SETTINGS_MODULE', 'project.settings')

from scrapy import project
from scrapy.conf import settings
from scrapy.crawler import CrawlerProcess

class CrawlerScript():

  def __init__(self):
    self.crawler = CrawlerProcess(settings)
    if not hasattr(project, 'crawler'):
      self.crawler.install()
    self.crawler.configure()

  def crawl(self, spider_name):
    spider = self.crawler.spiders.create(spider_name)   <--- line 19
    if spider:
      self.crawler.queue.append_spider(spider)
    self.crawler.start()
    self.crawler.stop()


# main
if __name__ == '__main__':
  crawler = CrawlerScript()
  crawler.crawl('etao')

the error is:

line 19: KeyError: 'Spider not found: etao'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:23:41+00:00Added an answer on May 30, 2026 at 5:23 pm

    you can actually call the crawlprocess yourself…

    its something like

    from scrapy.crawler import CrawlerProcess
    from scrapy.conf import settings
    
    
    settings.overrides.update({}) # your settings
    
    crawlerProcess = CrawlerProcess(settings)
    crawlerProcess.install()
    crawlerProcess.configure()
    
    crawlerProcess.crawl(spider) # your spider here
    

    Credits to @warwaruk.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://docs.python.org/3.0/whatsnew/3.0.html says it lists whats new , but in my opinion, it only lists
OK, maybe I'm dumb/blind, but in the docs it says rebuild and restart the
so live docs says this for calling .lenght() on an XML object For XML
When using svcutil.exe, I noticed this switch, /tcv:Version35. The docs says this: Version35: Use
The docs on ehache says: timeToIdleSeconds: Sets the time to idle for an element
I'm looking at the PayPal IPN docs , and it says the datetime stamps
jQuery Mobile Docs says if we wrap form element in div containing data-role=fieldcontain proper
I'm pretty new to TDD. I see some docs says about positive test, negative
Objective C docs from apple says For the object-oriented constructs of Objective-C, such as
i use the command line in windows to compile and then execute my java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.