Loading descarga_hacia_atras/diarioDeChiapas/diarioDeChiapas/spiders/noticias.py +3 −1 Changes for descarga_hacia_atras/diarioDeChiapas/diarioDeChiapas/spiders/noticias.py: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -5,13 +5,15 @@ MEDIA: Diario de Chiapas, Chiapas USAGE $ cd diarioDeChiapas $ cd diarioDeChiapas/ ------------------------------------------------------------------------------------------------------------ ## Get all the news from the most current to the oldest. It's necessary to use the parse_date_files.py file for the news contained in noticias.json being splitted into files by date. ## $ scrapy crawl noticias --nolog -s filename=noticias.json ------------------------------------------------------------------------------------------------------------ ## Get all the news from the most current to a specific date. ## $ scrapy crawl noticias --nolog -s filename=2018-08-30.json -a year=2018 -a month=8 -a day=30 """ Loading descarga_hacia_atras/foraneos/prensaHn/prensaHn/items.py +1 −1 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/items.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # Define here the models for your scraped items # # See documentation in: # http://doc.scrapy.org/en/latest/topics/items.html # https://doc.scrapy.org/en/latest/topics/items.html import scrapy Loading descarga_hacia_atras/foraneos/prensaHn/prensaHn/middlewares.py +52 −5 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/middlewares.py: 52 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # Define here the models for your spider middleware # # See documentation in: # http://doc.scrapy.org/en/latest/topics/spider-middleware.html # https://doc.scrapy.org/en/latest/topics/spider-middleware.html from scrapy import signals Loading @@ -20,14 +20,14 @@ class PrensahnSpiderMiddleware(object): crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) return s def process_spider_input(response, spider): def process_spider_input(self, response, spider): # Called for each response that goes through the spider # middleware and into the spider. # Should return None or raise an exception. return None def process_spider_output(response, result, spider): def process_spider_output(self, response, result, spider): # Called with the results returned from the Spider, after # it has processed the response. Loading @@ -35,7 +35,7 @@ class PrensahnSpiderMiddleware(object): for i in result: yield i def process_spider_exception(response, exception, spider): def process_spider_exception(self, response, exception, spider): # Called when a spider or process_spider_input() method # (from other spider middleware) raises an exception. Loading @@ -43,7 +43,7 @@ class PrensahnSpiderMiddleware(object): # or Item objects. pass def process_start_requests(start_requests, spider): def process_start_requests(self, start_requests, spider): # Called with the start requests of the spider, and works # similarly to the process_spider_output() method, except # that it doesn’t have a response associated. Loading @@ -54,3 +54,50 @@ class PrensahnSpiderMiddleware(object): def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name) class PrensahnDownloaderMiddleware(object): # Not all methods need to be defined. If a method is not defined, # scrapy acts as if the downloader middleware does not modify the # passed objects. @classmethod def from_crawler(cls, crawler): # This method is used by Scrapy to create your spiders. s = cls() crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) return s def process_request(self, request, spider): # Called for each request that goes through the downloader # middleware. # Must either: # - return None: continue processing this request # - or return a Response object # - or return a Request object # - or raise IgnoreRequest: process_exception() methods of # installed downloader middleware will be called return None def process_response(self, request, response, spider): # Called with the response returned from the downloader. # Must either; # - return a Response object # - return a Request object # - or raise IgnoreRequest return response def process_exception(self, request, exception, spider): # Called when a download handler or a process_request() # (from other downloader middleware) raises an exception. # Must either: # - return None: continue processing this exception # - return a Response object: stops process_exception() chain # - return a Request object: stops process_exception() chain pass def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name) descarga_hacia_atras/foraneos/prensaHn/prensaHn/pipelines.py +1 −1 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/pipelines.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html # See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html import json from collections import OrderedDict Loading descarga_hacia_atras/foraneos/prensaHn/prensaHn/settings.py +11 −11 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/settings.py: 11 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -5,9 +5,9 @@ # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # http://doc.scrapy.org/en/latest/topics/settings.html # http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html # http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html # https://doc.scrapy.org/en/latest/topics/settings.html # https://doc.scrapy.org/en/latest/topics/downloader-middleware.html # https://doc.scrapy.org/en/latest/topics/spider-middleware.html BOT_NAME = 'prensaHn' Loading @@ -25,7 +25,7 @@ NEWSPIDER_MODULE = 'prensaHn.spiders' #CONCURRENT_REQUESTS = 32 # Configure a delay for requests for the same website (default: 0) # See http://scrapy.readthedocs.org/en/latest/topics/settings.html#download-delay # See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay # See also autothrottle settings and docs DOWNLOAD_DELAY = 0.5 # The download delay setting will honor only one of: Loading @@ -45,31 +45,31 @@ COOKIES_ENABLED = False #} # Enable or disable spider middlewares # See http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html # See https://doc.scrapy.org/en/latest/topics/spider-middleware.html #SPIDER_MIDDLEWARES = { # 'prensaHn.middlewares.PrensahnSpiderMiddleware': 543, #} # Enable or disable downloader middlewares # See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html #DOWNLOADER_MIDDLEWARES = { # 'prensaHn.middlewares.MyCustomDownloaderMiddleware': 543, # 'prensaHn.middlewares.PrensahnDownloaderMiddleware': 543, #} # Enable or disable extensions # See http://scrapy.readthedocs.org/en/latest/topics/extensions.html # See https://doc.scrapy.org/en/latest/topics/extensions.html #EXTENSIONS = { # 'scrapy.extensions.telnet.TelnetConsole': None, #} # Configure item pipelines # See http://scrapy.readthedocs.org/en/latest/topics/item-pipeline.html # See https://doc.scrapy.org/en/latest/topics/item-pipeline.html ITEM_PIPELINES = { 'prensaHn.pipelines.JsonWriterPipeline': 300, } # Enable and configure the AutoThrottle extension (disabled by default) # See http://doc.scrapy.org/en/latest/topics/autothrottle.html # See https://doc.scrapy.org/en/latest/topics/autothrottle.html #AUTOTHROTTLE_ENABLED = True # The initial download delay #AUTOTHROTTLE_START_DELAY = 5 Loading @@ -82,7 +82,7 @@ ITEM_PIPELINES = { #AUTOTHROTTLE_DEBUG = False # Enable and configure HTTP caching (disabled by default) # See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings #HTTPCACHE_ENABLED = True #HTTPCACHE_EXPIRATION_SECS = 0 #HTTPCACHE_DIR = 'httpcache' Loading Loading
descarga_hacia_atras/diarioDeChiapas/diarioDeChiapas/spiders/noticias.py +3 −1 Changes for descarga_hacia_atras/diarioDeChiapas/diarioDeChiapas/spiders/noticias.py: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -5,13 +5,15 @@ MEDIA: Diario de Chiapas, Chiapas USAGE $ cd diarioDeChiapas $ cd diarioDeChiapas/ ------------------------------------------------------------------------------------------------------------ ## Get all the news from the most current to the oldest. It's necessary to use the parse_date_files.py file for the news contained in noticias.json being splitted into files by date. ## $ scrapy crawl noticias --nolog -s filename=noticias.json ------------------------------------------------------------------------------------------------------------ ## Get all the news from the most current to a specific date. ## $ scrapy crawl noticias --nolog -s filename=2018-08-30.json -a year=2018 -a month=8 -a day=30 """ Loading
descarga_hacia_atras/foraneos/prensaHn/prensaHn/items.py +1 −1 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/items.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # Define here the models for your scraped items # # See documentation in: # http://doc.scrapy.org/en/latest/topics/items.html # https://doc.scrapy.org/en/latest/topics/items.html import scrapy Loading
descarga_hacia_atras/foraneos/prensaHn/prensaHn/middlewares.py +52 −5 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/middlewares.py: 52 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # Define here the models for your spider middleware # # See documentation in: # http://doc.scrapy.org/en/latest/topics/spider-middleware.html # https://doc.scrapy.org/en/latest/topics/spider-middleware.html from scrapy import signals Loading @@ -20,14 +20,14 @@ class PrensahnSpiderMiddleware(object): crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) return s def process_spider_input(response, spider): def process_spider_input(self, response, spider): # Called for each response that goes through the spider # middleware and into the spider. # Should return None or raise an exception. return None def process_spider_output(response, result, spider): def process_spider_output(self, response, result, spider): # Called with the results returned from the Spider, after # it has processed the response. Loading @@ -35,7 +35,7 @@ class PrensahnSpiderMiddleware(object): for i in result: yield i def process_spider_exception(response, exception, spider): def process_spider_exception(self, response, exception, spider): # Called when a spider or process_spider_input() method # (from other spider middleware) raises an exception. Loading @@ -43,7 +43,7 @@ class PrensahnSpiderMiddleware(object): # or Item objects. pass def process_start_requests(start_requests, spider): def process_start_requests(self, start_requests, spider): # Called with the start requests of the spider, and works # similarly to the process_spider_output() method, except # that it doesn’t have a response associated. Loading @@ -54,3 +54,50 @@ class PrensahnSpiderMiddleware(object): def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name) class PrensahnDownloaderMiddleware(object): # Not all methods need to be defined. If a method is not defined, # scrapy acts as if the downloader middleware does not modify the # passed objects. @classmethod def from_crawler(cls, crawler): # This method is used by Scrapy to create your spiders. s = cls() crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) return s def process_request(self, request, spider): # Called for each request that goes through the downloader # middleware. # Must either: # - return None: continue processing this request # - or return a Response object # - or return a Request object # - or raise IgnoreRequest: process_exception() methods of # installed downloader middleware will be called return None def process_response(self, request, response, spider): # Called with the response returned from the downloader. # Must either; # - return a Response object # - return a Request object # - or raise IgnoreRequest return response def process_exception(self, request, exception, spider): # Called when a download handler or a process_request() # (from other downloader middleware) raises an exception. # Must either: # - return None: continue processing this exception # - return a Response object: stops process_exception() chain # - return a Request object: stops process_exception() chain pass def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name)
descarga_hacia_atras/foraneos/prensaHn/prensaHn/pipelines.py +1 −1 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/pipelines.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html # See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html import json from collections import OrderedDict Loading
descarga_hacia_atras/foraneos/prensaHn/prensaHn/settings.py +11 −11 Changes for descarga_hacia_atras/foraneos/prensaHn/prensaHn/settings.py: 11 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -5,9 +5,9 @@ # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # http://doc.scrapy.org/en/latest/topics/settings.html # http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html # http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html # https://doc.scrapy.org/en/latest/topics/settings.html # https://doc.scrapy.org/en/latest/topics/downloader-middleware.html # https://doc.scrapy.org/en/latest/topics/spider-middleware.html BOT_NAME = 'prensaHn' Loading @@ -25,7 +25,7 @@ NEWSPIDER_MODULE = 'prensaHn.spiders' #CONCURRENT_REQUESTS = 32 # Configure a delay for requests for the same website (default: 0) # See http://scrapy.readthedocs.org/en/latest/topics/settings.html#download-delay # See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay # See also autothrottle settings and docs DOWNLOAD_DELAY = 0.5 # The download delay setting will honor only one of: Loading @@ -45,31 +45,31 @@ COOKIES_ENABLED = False #} # Enable or disable spider middlewares # See http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html # See https://doc.scrapy.org/en/latest/topics/spider-middleware.html #SPIDER_MIDDLEWARES = { # 'prensaHn.middlewares.PrensahnSpiderMiddleware': 543, #} # Enable or disable downloader middlewares # See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html #DOWNLOADER_MIDDLEWARES = { # 'prensaHn.middlewares.MyCustomDownloaderMiddleware': 543, # 'prensaHn.middlewares.PrensahnDownloaderMiddleware': 543, #} # Enable or disable extensions # See http://scrapy.readthedocs.org/en/latest/topics/extensions.html # See https://doc.scrapy.org/en/latest/topics/extensions.html #EXTENSIONS = { # 'scrapy.extensions.telnet.TelnetConsole': None, #} # Configure item pipelines # See http://scrapy.readthedocs.org/en/latest/topics/item-pipeline.html # See https://doc.scrapy.org/en/latest/topics/item-pipeline.html ITEM_PIPELINES = { 'prensaHn.pipelines.JsonWriterPipeline': 300, } # Enable and configure the AutoThrottle extension (disabled by default) # See http://doc.scrapy.org/en/latest/topics/autothrottle.html # See https://doc.scrapy.org/en/latest/topics/autothrottle.html #AUTOTHROTTLE_ENABLED = True # The initial download delay #AUTOTHROTTLE_START_DELAY = 5 Loading @@ -82,7 +82,7 @@ ITEM_PIPELINES = { #AUTOTHROTTLE_DEBUG = False # Enable and configure HTTP caching (disabled by default) # See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings #HTTPCACHE_ENABLED = True #HTTPCACHE_EXPIRATION_SECS = 0 #HTTPCACHE_DIR = 'httpcache' Loading