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
067f09e9
Commit
067f09e9
authored
Apr 15, 2020
by
Mario Chirinos Colunga
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
noticiero en linea
parent
57f362cd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
noticias.py
...por_dia/noticieroLinea/noticieroLinea/spiders/noticias.py
+9
-5
No files found.
descarga_por_dia/noticieroLinea/noticieroLinea/spiders/noticias.py
View file @
067f09e9
...
...
@@ -8,15 +8,18 @@ Noticiero en Línea, Colima
USO:
scrapy crawl noticias --nolog -s filename=2018-01-03.json -a year=2018 -a month=1 -a day=3
"""
from
dateparser
import
parse
TAG_RE
=
re
.
compile
(
r'<[^>]+>'
)
def
remove_tags
(
text
):
return
TAG_RE
.
sub
(
''
,
text
)
LOC_RE
=
re
.
compile
(
r'\A.+?(\d{1,2}[\s-][a-zA-Z]+[\s-]\d{4})?\s?\.\s?-\s?'
,
re
.
S
)
G_RE
=
re
.
compile
(
r'\s?-\s?'
)
E_RE
=
re
.
compile
(
r'\(Con informaci.*?\)\.?'
)
#-------------------------------------------------------------------------------
def
remove_tags
(
text
):
return
TAG_RE
.
sub
(
''
,
text
)
#-------------------------------------------------------------------------------
class
QuotesSpider
(
scrapy
.
Spider
):
name
=
"noticias"
...
...
@@ -44,7 +47,8 @@ class QuotesSpider(scrapy.Spider):
text
=
''
"La fecha obtenida ya incluye formato y zona horaria"
item
[
'date'
]
=
response
.
xpath
(
'//meta[@property="article:published_time"]/@content'
)
.
extract_first
()
date
=
response
.
css
(
"span.entry-meta-date::text"
)
.
get
()
.
lower
()
item
[
'date'
]
=
parse
(
date
,
date_formats
=
[
"
%
d
%
B,
%
Y"
])
.
isoformat
()
#response.xpath('//meta[@property="article:published_time"]/@content').extract_first()
item
[
'title'
]
=
remove_tags
(
response
.
xpath
(
'//h1[@class="entry-title"]'
)
.
extract_first
())
.
strip
()
item
[
'topic'
]
=
response
.
xpath
(
'//*[@class="entry-tags clearfix"]/a/text()'
)
.
extract_first
()
...
...
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