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
f6e99c05
Commit
f6e99c05
authored
Mar 02, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crawlers
parent
32d4ecab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
3 deletions
+52
-3
items.py
...dia/paisElSalvador/diarioCoLatino/diarioCoLatino/items.py
+2
-0
items.pyc
...ia/paisElSalvador/diarioCoLatino/diarioCoLatino/items.pyc
+0
-0
noticias.py
...alvador/diarioCoLatino/diarioCoLatino/spiders/noticias.py
+50
-3
noticias.pyc
...lvador/diarioCoLatino/diarioCoLatino/spiders/noticias.pyc
+0
-0
No files found.
descarga_por_dia/paisElSalvador/diarioCoLatino/diarioCoLatino/items.py
View file @
f6e99c05
...
...
@@ -18,3 +18,5 @@ class NoticiasItem(scrapy.Item):
author
=
scrapy
.
Field
()
topic
=
scrapy
.
Field
()
url
=
scrapy
.
Field
()
twitter
=
scrapy
.
Field
()
email
=
scrapy
.
Field
()
descarga_por_dia/paisElSalvador/diarioCoLatino/diarioCoLatino/items.pyc
View file @
f6e99c05
No preview for this file type
descarga_por_dia/paisElSalvador/diarioCoLatino/diarioCoLatino/spiders/noticias.py
View file @
f6e99c05
...
...
@@ -13,14 +13,18 @@ TAG_RE = re.compile(r'<[^>]+>')
def
remove_tags
(
text
):
return
TAG_RE
.
sub
(
''
,
text
)
# LOC_RE = re.compile(r'\n.+?,? ?.+? ?\. ?- ?')
# G_RE = re.compile(r' ?- ?')
# EM_RE = re.compile(r'((Email|Correo electr.{1,3}nico|Comentarios?):\s)?[\w.-]+@[\w-]+(\.[a-zA-Z]{2,6}){1,2}\s?')
# TW_RE = re.compile(r'M.{1,3}s de la P.{1,3}lvora en Twitter: @[\w.%+-]+.', re.I)
# TW2_RE = re.compile(r'((\| )?Twitter:\s+)?(@[\w.%+-]+.)?', re.I)
# TAG2_RE = re.compile(r'\ntransition_[^\]]+\]')
# TAG3_RE = re.compile(r'\[[^\]]+[\]\n]')
AUTH_RE
=
re
.
compile
(
r'\nPor.+?\n'
)
TW_RE
=
re
.
compile
(
r'(\n(\| )?Twitter:\s+)?(@[\w.
%+-
]+.)'
,
re
.
I
)
LOC_RE
=
re
.
compile
(
r'\n.*?\/(PL|AFP|DPA)'
,
re
.
I
)
EM_RE
=
re
.
compile
(
r'(\n(Email|Correo electr.{1,3}nico|Comentarios?):\s)?[\w.-]+@[\w-]+(\.[a-zA-Z]{2,6}){1,2}\s?'
)
#** correo pasarlo dos veces seguidas
#Frases a quitar: '\nFotografías\n', '\nDiario Co Latino\n'
class
QuotesSpider
(
scrapy
.
Spider
):
name
=
"noticias"
...
...
@@ -68,6 +72,49 @@ class QuotesSpider(scrapy.Spider):
for
p
in
response
.
xpath
(
'//div[@class="entry"]/div/span'
)
.
extract
():
text
+=
remove_tags
(
p
)
+
"
\n
"
text
=
"
\n
"
+
text
""" Obtiene autor """
res
=
AUTH_RE
.
search
(
text
)
if
res
:
m
=
res
.
group
(
0
)
item
[
'author'
]
=
m
[
m
.
find
(
'Por'
)
+
len
(
'Por'
):]
.
strip
()
text
=
text
[
text
.
find
(
m
)
+
len
(
m
):]
.
strip
()
text
=
"
\n
"
+
text
""" Elimina twitter """
res
=
TW_RE
.
search
(
text
)
if
res
:
m
=
res
.
group
(
0
)
item
[
'twitter'
]
=
m
.
strip
()
text
=
text
[
text
.
find
(
m
)
+
len
(
m
):]
.
strip
()
text
=
"
\n
"
+
text
""" Obtiene lugar """
res
=
LOC_RE
.
search
(
text
)
if
res
:
m
=
res
.
group
(
0
)
if
m
[
m
.
find
(
'/'
)
+
1
:]
.
strip
()
.
lower
()
!=
'dpa'
:
item
[
'location'
]
=
m
[:
m
.
find
(
'/'
)]
.
strip
()
text
=
text
[
text
.
find
(
m
)
+
len
(
m
):]
.
strip
()
text
=
"
\n
"
+
text
""" Elimina correo """
res
=
EM_RE
.
search
(
text
)
if
res
:
m
=
res
.
group
(
0
)
item
[
'email'
]
=
m
.
strip
()
text
=
text
[
text
.
find
(
m
)
+
len
(
m
):]
.
strip
()
text
=
"
\n
"
+
text
res
=
EM_RE
.
search
(
text
)
if
res
:
m
=
res
.
group
(
0
)
item
[
'email'
]
=
m
.
strip
()
text
=
text
[
text
.
find
(
m
)
+
len
(
m
):]
.
strip
()
text
=
"
\n
"
+
text
text
[
text
.
find
(
"
\n
Diario Co Latino
\n
"
)
+
len
(
"
\n
Diario Co Latino
\n
"
)]
# result = LOC_RE.search(text)
# if result:
# m = result.group(0)
...
...
descarga_por_dia/paisElSalvador/diarioCoLatino/diarioCoLatino/spiders/noticias.pyc
View file @
f6e99c05
No preview for this file type
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