Scrapy를 잘 사용하기 위해 구조와 작동 순서를 아는것이 필요. Components Scrapy는 아래와 같은 component들로 구성되어 있다. Scrapy Engine 각 component들에 데이터(Request, Response, Item)를 전달(Controller)하고 액션이 발생 했을 때 이벤트를 발생시키는 역활을 함. Scheduler 엔진으로 부터 Request을 전달 받고 이 Request을 queue에 추가한 후 나중에 엔진이 Request를 요청할 때 다시 엔진에 전달. Downloader Request에 포함된 URL에서 웹 페이지를 가져와서 Response 오브젝트를 만들어 엔진에게 전달하는 역활을 한다. 엔진은 전달 받은 이 웹 페이지를 다시 스파이더에게 전달. Spide..
설치 $ pip install scrapy 프로젝트 생성 $ scrapy startproject project_name 아래와 같이 디렉토리와 파일들이 생성됨 $ tree project_name project_name ├── scrapy.cfg └── project_name ├── __init__.py ├── items.py ├── middlewares.py ├── pipelines.py ├── settings.py └── spiders └── __init__.py 간단 spider 생성 Spiders 디렉토리 안에 파이썬 파일 생성 $ cd project_name/project_name/spiders $ touch example.py scrapy.Spider를 상속하는 클래스를 생성 # example...