Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
crawlersNoticias
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
m3
crawlersNoticias
Commits
9fd0391f
Commit
9fd0391f
authored
Oct 25, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crawlers
parent
30b928b1
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
250 additions
and
170 deletions
+250
-170
noticias.py
...atras/diarioDeChiapas/diarioDeChiapas/spiders/noticias.py
+3
-1
items.py
descarga_hacia_atras/foraneos/prensaHn/prensaHn/items.py
+1
-1
middlewares.py
...rga_hacia_atras/foraneos/prensaHn/prensaHn/middlewares.py
+52
-5
pipelines.py
descarga_hacia_atras/foraneos/prensaHn/prensaHn/pipelines.py
+1
-1
settings.py
descarga_hacia_atras/foraneos/prensaHn/prensaHn/settings.py
+11
-11
noticias.py
...acia_atras/foraneos/prensaHn/prensaHn/spiders/noticias.py
+159
-131
scrapy.cfg
descarga_hacia_atras/foraneos/prensaHn/scrapy.cfg
+1
-1
noticias.py
...ras/heraldoChihuahua/heraldoChihuahua/spiders/noticias.py
+3
-1
noticias.py
...cia_atras/laJornadaMaya/laJornadaMaya/spiders/noticias.py
+12
-13
noticias.py
...a_hacia_atras/tintaFresca/tintaFresca/spiders/noticias.py
+5
-3
noticias.py
descarga_por_dia/cuartoPoder/cuartoPoder/spiders/noticias.py
+2
-2
No files found.
descarga_hacia_atras/diarioDeChiapas/diarioDeChiapas/spiders/noticias.py
View file @
9fd0391f
...
...
@@ -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
"""
...
...
descarga_hacia_atras/foraneos/prensaHn/prensaHn/items.py
View file @
9fd0391f
...
...
@@ -3,7 +3,7 @@
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
# http
s
://doc.scrapy.org/en/latest/topics/items.html
import
scrapy
...
...
descarga_hacia_atras/foraneos/prensaHn/prensaHn/middlewares.py
View file @
9fd0391f
...
...
@@ -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
# http
s
://doc.scrapy.org/en/latest/topics/spider-middleware.html
from
scrapy
import
signals
...
...
@@ -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.
...
...
@@ -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.
...
...
@@ -43,7 +43,7 @@ class PrensahnSpiderMiddleware(object):
# or Item objects.
pass
def
process_start_requests
(
start_requests
,
spider
):
def
process_start_requests
(
s
elf
,
s
tart_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.
...
...
@@ -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
View file @
9fd0391f
...
...
@@ -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: http
s
://doc.scrapy.org/en/latest/topics/item-pipeline.html
import
json
from
collections
import
OrderedDict
...
...
descarga_hacia_atras/foraneos/prensaHn/prensaHn/settings.py
View file @
9fd0391f
...
...
@@ -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
# http
s
://doc.scrapy.org/en/latest/topics/settings.html
# http
s://doc.scrapy
.org/en/latest/topics/downloader-middleware.html
# http
s://doc.scrapy
.org/en/latest/topics/spider-middleware.html
BOT_NAME
=
'prensaHn'
...
...
@@ -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 http
s://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:
...
...
@@ -45,31 +45,31 @@ COOKIES_ENABLED = False
#}
# Enable or disable spider middlewares
# See http
://scrapy.readthedocs
.org/en/latest/topics/spider-middleware.html
# See http
s://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 http
s://doc.scrapy
.org/en/latest/topics/downloader-middleware.html
#DOWNLOADER_MIDDLEWARES = {
# 'prensaHn.middlewares.
MyCustom
DownloaderMiddleware': 543,
# 'prensaHn.middlewares.
Prensahn
DownloaderMiddleware': 543,
#}
# Enable or disable extensions
# See http
://scrapy.readthedocs
.org/en/latest/topics/extensions.html
# See http
s://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 http
s://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 http
s
://doc.scrapy.org/en/latest/topics/autothrottle.html
#AUTOTHROTTLE_ENABLED = True
# The initial download delay
#AUTOTHROTTLE_START_DELAY = 5
...
...
@@ -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 http
s://doc.scrapy
.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
#HTTPCACHE_ENABLED = True
#HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = 'httpcache'
...
...
descarga_hacia_atras/foraneos/prensaHn/prensaHn/spiders/noticias.py
View file @
9fd0391f
This diff is collapsed.
Click to expand it.
descarga_hacia_atras/foraneos/prensaHn/scrapy.cfg
View file @
9fd0391f
# Automatically created by: scrapy startproject
#
# For more information about the [deploy] section see:
# https://scrapyd.readthedocs.
org
/en/latest/deploy.html
# https://scrapyd.readthedocs.
io
/en/latest/deploy.html
[settings]
default = prensaHn.settings
...
...
descarga_hacia_atras/heraldoChihuahua/heraldoChihuahua/spiders/noticias.py
View file @
9fd0391f
...
...
@@ -5,13 +5,15 @@ MEDIA:
El Heraldo de Chihuahua, Chihuahua
USAGE
$ cd heraldoChihuahua
$ cd heraldoChihuahua
/
------------------------------------------------------------------------------------------------------------
## 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
"""
...
...
descarga_hacia_atras/laJornadaMaya/laJornadaMaya/spiders/noticias.py
View file @
9fd0391f
...
...
@@ -67,8 +67,7 @@ class QuotesSpider(scrapy.Spider):
request
.
meta
[
'item'
]
=
flow_info
yield
request
else
:
if
year
is
None
and
month
is
None
and
day
is
None
:
elif
year
is
None
and
month
is
None
and
day
is
None
:
self
.
stop_date
=
None
for
s
in
section_list
:
...
...
descarga_hacia_atras/tintaFresca/tintaFresca/spiders/noticias.py
View file @
9fd0391f
...
...
@@ -5,13 +5,15 @@ MEDIA:
Tinta Fresca, Chiapas
USAGE
$ cd tintaFresca
$ cd tintaFresca
/
------------------------------------------------------------------------------------------------------------
## 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
"""
...
...
@@ -69,8 +71,8 @@ class QuotesSpider(scrapy.Spider):
baseURL
=
"http://tintafresca.com.mx/"
#
section_list = ["letras_en_su_tinta/page1/", "tgz/page1/", "patria_chica/page1/", "hecho_en_chiapas/page1/", "show/page1/", "rafaga/page1/"]
section_list
=
[
"tgz/page1/"
,
"patria_chica/page1/"
,
"hecho_en_chiapas/page1/"
,
"show/page1/"
]
section_list
=
[
"letras_en_su_tinta/page1/"
,
"tgz/page1/"
,
"patria_chica/page1/"
,
"hecho_en_chiapas/page1/"
,
"show/page1/"
,
"rafaga/page1/"
]
#
section_list = ["tgz/page1/", "patria_chica/page1/", "hecho_en_chiapas/page1/", "show/page1/"]
self
.
month_parser
=
dict
(
Enero
=
'01'
,
Febrero
=
'02'
,
Marzo
=
'03'
,
Abril
=
'04'
,
Mayo
=
'05'
,
Junio
=
'06'
,
Julio
=
'07'
,
Agosto
=
'08'
,
Septiembre
=
'09'
,
Octubre
=
'10'
,
Noviembre
=
'11'
,
Diciembre
=
'12'
)
...
...
descarga_por_dia/cuartoPoder/cuartoPoder/spiders/noticias.py
View file @
9fd0391f
...
...
@@ -76,7 +76,7 @@ class QuotesSpider(scrapy.Spider):
flow_info
=
response
.
meta
[
'item'
]
for
link
in
response
.
css
(
'ul.news-list'
)
.
xpath
(
'./li/h5/a/@href'
)
.
extract
():
to_next_page
=
True
flow_info
[
'to_next_page'
]
=
True
news_link
=
self
.
baseURL
+
link
yield
scrapy
.
Request
(
url
=
news_link
,
callback
=
self
.
parse_item
)
...
...
@@ -102,7 +102,7 @@ class QuotesSpider(scrapy.Spider):
news_date
=
datetime
(
int
(
self
.
year
),
int
(
self
.
month
),
int
(
self
.
day
),
tzinfo
=
self
.
tz
)
.
isoformat
(
"T"
)
title
=
response
.
css
(
'div.post-title'
)
.
css
(
'h1'
)
.
extract_first
()
if
title
is
not
None
:
remove_tags
(
title
)
if
title
is
not
None
:
title
=
remove_tags
(
title
)
topic
=
response
.
css
(
'div.big-title'
)
.
xpath
(
'./h2/a/span'
)
.
extract_first
()
if
topic
is
not
None
:
topic
=
remove_tags
(
topic
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment