scrapy系列教程二——命令行工具(Command line tools)

1.命令行工具(Command line tools)

   Scrapy是通过Scrapy命令行工具进行控制的。这里我们称之为 “Scrapy tool” 以用来和子命令进行区分。 对于子命令,我们称为 “command” 或者 “Scrapy commands”。Scrapy tool 针对不同的目的提供了多个命令,每个命令支持不同的参数和选项。

2.常用命令

   官方命令行说明文档 http://scrapy-chs.readthedocs.org/zh_CN/latest/topics/commands.html

  • 查看所有可用的命令 scrapy -h
  • 创建scrapy项目 : scrapy startproject myproject(工程名字)

        接下来,进入到项目目录中: cd myproject

   项目默认目录结构:

       scrapy.cfg
       myproject/
           __init__.py
          items.py
          pipelines.py
          settings.py
          spiders/
              __init__.py
              spider1.py
              spider2.py
               ...
  • 列出所有可用爬虫 : scrapy list
  •  启动一个爬虫:scrapy crawl <spidername>  其中spidernae是在爬虫文件里声明的

  •  scrapy终端 :scrapy shell [url]  这个是常用的,可以验证调试你写的xpath

     scrapy终端官方教程 http://scrapy-chs.readthedocs.org/zh_CN/latest/topics/shell.html

posted @ 2015-08-10 12:55  败八  阅读(412)  评论(0编辑  收藏  举报