나는 과 같은 많은 수의 Scrapy
튜토리얼을 발견했으며, 아래에 나와있는 단계가 필요합니다. 결과는 많은 파일 (project.cfg
+ 일부 .py
개의 파일 + 특정 폴더 구조)을 가진 프로젝트입니다.자체 포함 된 python 파일의 웹 크롤러
아래의 단계를 수행하는 방법은python mycrawler.py
과 함께 실행될 수있는 독립적 인 파이썬 파일로 작동합니까? 대신 파일을 많이, 일부 .CFG 파일 등, 그리고 방법에 의해 scrapy crawl myproject -o myproject.json
...를 사용하지와 전체 프로젝트의
(,이 사실입니까? scrapy
새로운 쉘 명령 것 같다?)
참고 : here could be an answer to this question 참고 : 불행히도 더 이상 사용되지 않으며 더 이상 작동하지 않습니다. 정의)
from scrapy.item import Item, Field
class MyItem(Item):
title = Field()
link = Field()
...
3
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
class MySpider(BaseSpider):
name = "myproject"
allowed_domains = ["example.com"]
start_urls = ["http://www.example.com"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
...
와 크롤러 :
1) 이런 Item
와 데이터 구조 정의) scrapy startproject myproject
2 새로운 scrapy 프로젝트를 작성
4) 실행 프로그램 :
scrapy crawl myproject -o myproject.json
이것을 실행할 수 있습니까? 이 설명을 간단히 설명 할 수 있습니까? – aibotnet
@vikasdumca 사실이 자습서 (http://amaral-lab.org/blog/quick-introduction-web-crawling-using-scrapy-part-)는 runnable-in-one-script 코드를 만드는 법을 보여줍니다. 하나의 파일'testcrawler.py'에 http://amaral-lab.org/blog/quick-introduction-web-crawling-using-scrapy-part-을 할 수 있고 그것을 실행할 수 있기를 원합니다. 'python testcrawler.py' 대신'scrapy ...'를 실행해야합니다. – Basj