Commit 54164b6d authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

crawlers

parent d715b956
...@@ -11,6 +11,9 @@ from collections import OrderedDict ...@@ -11,6 +11,9 @@ from collections import OrderedDict
class JsonWriterPipeline(object): class JsonWriterPipeline(object):
def __init__(self, filename):
self.filename = filename
@classmethod @classmethod
def from_crawler(cls, crawler): def from_crawler(cls, crawler):
# Here you get whatever value was passed through the "filename" command line parameter # Here you get whatever value was passed through the "filename" command line parameter
...@@ -20,9 +23,6 @@ class JsonWriterPipeline(object): ...@@ -20,9 +23,6 @@ class JsonWriterPipeline(object):
# Instantiate the pipeline with the file name # Instantiate the pipeline with the file name
return cls(filename) return cls(filename)
def __init__(self, filename):
self.filename = filename
def open_spider(self, spider): def open_spider(self, spider):
self.counter = 0 self.counter = 0
self.file = open(self.filename, 'w') self.file = open(self.filename, 'w')
......
...@@ -2,7 +2,7 @@ import scrapy, re ...@@ -2,7 +2,7 @@ import scrapy, re
""" """
USO: USO:
scrapy crawl noticias -t json --nolog -s filename=2018-03-22.json -a year=2017 -a month=3 -a day=22 scrapy crawl noticias --nolog -s filename=2018-03-22.json -a year=2017 -a month=3 -a day=22
""" """
TAG_RE = re.compile(r'<[^>]+>') TAG_RE = re.compile(r'<[^>]+>')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment