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
5c3ec077
Commit
5c3ec077
authored
Dec 18, 2017
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crawl rss
parent
ca85aaa9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
6 deletions
+92
-6
crawl_rss.py
crawler_script/crawl_rss.py
+92
-6
No files found.
crawler_script/crawl_rss.py
View file @
5c3ec077
...
@@ -4,10 +4,12 @@ import sys
...
@@ -4,10 +4,12 @@ import sys
import
json
import
json
import
os
import
os
import
datetime
import
datetime
from
collections
import
OrderedDict
today
=
datetime
.
datetime
.
now
()
today
=
datetime
.
datetime
.
now
()
baseDir
=
"/home/geoint/virtualHDD/m3/noticias/"
baseDir
=
"/home/geoint/virtualHDD/m3/noticias/"
scrapyDir
=
"/home/geoint/crawlersNoticias/"
scrapyDir
=
"/home/geoint/crawlersNoticias/"
row
=
{}
with
open
(
sys
.
argv
[
1
])
as
data_file
:
with
open
(
sys
.
argv
[
1
])
as
data_file
:
siteList
=
json
.
load
(
data_file
)
siteList
=
json
.
load
(
data_file
)
os
.
chdir
(
baseDir
)
os
.
chdir
(
baseDir
)
...
@@ -84,16 +86,58 @@ with open(sys.argv[1]) as data_file:
...
@@ -84,16 +86,58 @@ with open(sys.argv[1]) as data_file:
for
line
in
master
:
for
line
in
master
:
counter
+=
1
counter
+=
1
if
media
==
'elFinanciero'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
elif
media
==
'elUniversal'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'location'
,
line
[
'location'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
if
counter
==
1
:
if
counter
==
1
:
infile3
.
write
(
json
.
dumps
(
line
))
infile3
.
write
(
json
.
dumps
(
row
))
elif
counter
>
1
:
elif
counter
>
1
:
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
line
))
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
row
))
for
line
in
slave
:
for
line
in
slave
:
if
not
line
[
'url'
]
in
urlSet
:
if
not
line
[
'url'
]
in
urlSet
:
lineDate
=
datetime
.
datetime
.
strptime
(
line
[
'date'
][:
10
],
'
%
Y-
%
m-
%
d'
)
lineDate
=
datetime
.
datetime
.
strptime
(
line
[
'date'
][:
10
],
'
%
Y-
%
m-
%
d'
)
if
lineDate
==
currentDate
:
if
lineDate
==
currentDate
:
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
line
))
if
media
==
'elFinanciero'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
elif
media
==
'elUniversal'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'location'
,
line
[
'location'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
row
))
elif
(
currentDate
-
lineDate
)
.
days
==
1
:
elif
(
currentDate
-
lineDate
)
.
days
==
1
:
YESTERDAY
=
True
YESTERDAY
=
True
...
@@ -119,15 +163,57 @@ with open(sys.argv[1]) as data_file:
...
@@ -119,15 +163,57 @@ with open(sys.argv[1]) as data_file:
for
line
in
master
:
for
line
in
master
:
counter
+=
1
counter
+=
1
if
media
==
'elFinanciero'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
elif
media
==
'elUniversal'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'location'
,
line
[
'location'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
if
counter
==
1
:
if
counter
==
1
:
infile3
.
write
(
json
.
dumps
(
line
))
infile3
.
write
(
json
.
dumps
(
row
))
elif
counter
>
1
:
elif
counter
>
1
:
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
line
))
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
row
))
for
line
in
slave
:
for
line
in
slave
:
lineDate
=
datetime
.
datetime
.
strptime
(
line
[
'date'
][:
10
],
'
%
Y-
%
m-
%
d'
)
lineDate
=
datetime
.
datetime
.
strptime
(
line
[
'date'
][:
10
],
'
%
Y-
%
m-
%
d'
)
if
not
line
[
'url'
]
in
urlSet
and
lineDate
==
currentDate
:
if
not
line
[
'url'
]
in
urlSet
and
lineDate
==
currentDate
:
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
line
))
if
media
==
'elFinanciero'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
elif
media
==
'elUniversal'
:
row
=
OrderedDict
([
(
'date'
,
line
[
'date'
]),
(
'topic'
,
line
[
'topic'
]),
(
'title'
,
line
[
'title'
]),
(
'author'
,
line
[
'author'
]),
(
'location'
,
line
[
'location'
]),
(
'url'
,
line
[
'url'
]),
(
'text'
,
line
[
'text'
])
])
infile3
.
write
(
',
\n
'
+
json
.
dumps
(
row
))
infile3
.
write
(
']'
)
infile3
.
write
(
']'
)
...
...
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