1. scrapy 框架应该怎么学习(前言)
阅读原文时间:2023年07月09日阅读:1

其实 scrapy 框架并不难学习, 我觉得分为两部分: 命令代码逻辑的构建

1. 如何学习命令

其实 scrapy 已经帮我们做好了很充足的说明了, 下面我来说如何好好利用这些说明
scrapy 分为 全局命令项目命令 俩中命令, 全局命令可以在项目目录下使用也可以不在项目目录下使用, 而项目命令只能在项目目录下才能使用, 知道这一点便于理解我们命令的使用场景
当你什么都不知道的时候善于 用 -h 参数, 比如你安装好了 scrapy 后

scrapy  -h
Usage:
  scrapy <command> [options] [args]

Available commands:
  bench         Run quick benchmark test
  fetch         Fetch a URL using the Scrapy downloader
  genspider     Generate new spider using pre-defined templates
  runspider     Run a self-contained spider (without creating a project)
  settings      Get settings values
  shell         Interactive scraping console
  startproject  Create new project
  version       Print Scrapy version
  view          Open URL in browser, as seen by Scrapy

  [ more ]      More commands available when run from project directory

Use "scrapy <command> -h" to see more info about a command

清晰明了, 每一条命令干什么的都已经进行了详细的说明了, 而你想进一步使用命令需要知道加什么参数, 这时候你可以(比如你想知道 startproject 这条命令具体怎么用)

scrapy startproject -h
Usage
  scrapy startproject <project_name> [project_dir]

Create new project

Options
--help, -h              show this help message and exit

Global Options
--logfile=FILE          log file. if omitted stderr will be used
--loglevel=LEVEL, -L LEVEL
                        log level (default: DEBUG)
--nolog                 disable logging completely
--profile=FILE          write python cProfile stats to FILE
--pidfile=FILE          write process ID to FILE
--set=NAME=VALUE, -s NAME=VALUE
                        set/override setting (may be repeated)
--pdb                   enable pdb on failure

命令的详细使用方法就已经打印出来了