Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

document new genspider behavior

Valdir Stumm Junior081595a2e49d
diff --git a/docs/topics/commands.rst b/docs/topics/commands.rst
index 9a40a2c29..d7999900b 100644
--- a/docs/topics/commands.rst
+++ b/docs/topics/commands.rst
@@ -159,6 +159,7 @@ settings).
Global commands:
* :command:`startproject`
+* :command:`genspider`
* :command:`settings`
* :command:`runspider`
* :command:`shell`
@@ -173,7 +174,6 @@ Project-only commands:
* :command:`list`
* :command:`edit`
* :command:`parse`
-* :command:`genspider`
* :command:`bench`
.. command:: startproject
@@ -197,14 +197,9 @@ genspider
---------
* Syntax: ``scrapy genspider [-t template] <name> <domain>``
-* Requires project: *yes*
-
-Create a new spider in the current project.
+* Requires project: *no*
-This is just a convenience shortcut command for creating spiders based on
-pre-defined templates, but certainly not the only way to create spiders. You
-can just create the spider source code files yourself, instead of using this
-command.
+Create a new spider in the current folder or in the current project's ``spiders`` folder, if called from inside a project. The ``<name>`` parameter is set as the spider's ``name``, while ``<domain>`` is used to generate the ``allowed_domains`` and ``start_urls`` spider's attributes.
Usage example::
@@ -215,22 +210,16 @@ Usage example::
csvfeed
xmlfeed
- $ scrapy genspider -d basic
- import scrapy
+ $ scrapy genspider example example.com
+ Created spider 'example' using template 'basic'
- class $classname(scrapy.Spider):
- name = "$name"
- allowed_domains = ["$domain"]
- start_urls = (
- 'http://www.$domain/',
- )
+ $ scrapy genspider -t crawl scrapyorg scrapy.org
+ Created spider 'scrapyorg' using template 'crawl'
- def parse(self, response):
- pass
-
- $ scrapy genspider -t basic example example.com
- Created spider 'example' using template 'basic' in module:
- mybot.spiders.example
+This is just a convenience shortcut command for creating spiders based on
+pre-defined templates, but certainly not the only way to create spiders. You
+can just create the spider source code files yourself, instead of using this
+command.
.. command:: crawl