mirror of https://github.com/scrapy/scrapy.git
document new genspider behavior
This commit is contained in:
parent
8987b17730
commit
081595a2e4
|
|
@ -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*
|
||||
* Requires project: *no*
|
||||
|
||||
Create a new spider in the current project.
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue