반응형

Scrapy 명령 도구는 다양한 인수 옵션 그룹이있는 다양한 객체에 대한 명령이 포함되어 있고 주로 'Scrapy tool'이라고도하는 Scrapy 제어하는 사용됩니다.


========================

scrapy.cfg                - Deploy the configuration file

project_name/             - Name of the project

   _init_.py

   items.py               - It is project's items file

   pipelines.py           - It is project's pipelines file

   settings.py            - It is project's settings file

   spiders                - It is the spiders directory

      _init_.py

      spider_name.py

      . . .

============================  


위와 같은 구조를 가지고 있습니다.

scrapy.cfg 파일이 프로젝트 이름과 프로젝트 세팅을 담고있는 프로젝트 root 디렉토리입니다.


예를 들자면,


[settings] 

default = [name of the project].settings  


[deploy] 

#url = http://localhost:6800/ 

project = [name of the project] 

==================================


이렇게 생겼습니다.


Scrapy Tool 사용법


scrapy tool 밑에 보이는 커맨드와 사용법을 제공하고있습니다.


=============================================================

Scrapy X.Y  - no active project 

Usage: 

   scrapy  [options] [arguments] 

Available commands: 

   crawl      It puts spider (handle the URL) to work for crawling data 

   fetch      It fetches the response from the given URL

=============================================================


프로젝트 생성


scrapy startproject project_name으로 간단히 프로젝트를 생성할 있습니다.


앞으로 헷갈리지않도록 scrapy  전용 폴더를 만들어줍시다.

그리고는

scrape start project project_name 명령어를 통해 

본견적으로 시작해봅시다.

친절하게 아래에 명령어를 통해 스파이더를 시작할 수 있음! 이라고 해주네요

cd project_name

scrape gen spider example example.com

저는  logan이라고 이름을 지었습니다.

tree해보시면 전반적 구조가 보이실거에요.


중간에 궁금하신게 있으시다면 

scrape -h 명령어를 통해 확인가능합니다.


반응형
by 발전소장 에르 :) 2017. 10. 17. 12:16