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
7d116982
Commit
7d116982
authored
Dec 01, 2017
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crawlers
parent
81ee8b42
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
49 deletions
+52
-49
__init__.pyc
descarga_por_dia/puntoMedio/puntoMedio/__init__.pyc
+0
-0
settings.pyc
descarga_por_dia/puntoMedio/puntoMedio/settings.pyc
+0
-0
__init__.pyc
descarga_por_dia/puntoMedio/puntoMedio/spiders/__init__.pyc
+0
-0
noticias.py
descarga_por_dia/puntoMedio/puntoMedio/spiders/noticias.py
+52
-49
noticias.pyc
descarga_por_dia/puntoMedio/puntoMedio/spiders/noticias.pyc
+0
-0
No files found.
descarga_por_dia/puntoMedio/puntoMedio/__init__.pyc
View file @
7d116982
No preview for this file type
descarga_por_dia/puntoMedio/puntoMedio/settings.pyc
View file @
7d116982
No preview for this file type
descarga_por_dia/puntoMedio/puntoMedio/spiders/__init__.pyc
View file @
7d116982
No preview for this file type
descarga_por_dia/puntoMedio/puntoMedio/spiders/noticias.py
View file @
7d116982
import
scrapy
,
re
## scrapy crawl noticias -t json --nolog -o noticias.json -a year=2017 -a month=3 -a day=22
'''
scrapy crawl noticias -t json --nolog -o noticias.json -a year=2017 -a month=9 -a day=28
'''
TAG_RE
=
re
.
compile
(
r'<[^>]+>'
)
def
remove_tags
(
text
):
...
...
@@ -21,11 +21,12 @@ class NoticiasItem(scrapy.Item):
class
QuotesSpider
(
scrapy
.
Spider
):
name
=
"noticias"
def
start_requests
(
self
):
year
=
getattr
(
self
,
'year'
,
None
)
month
=
getattr
(
self
,
'month'
,
None
)
day
=
getattr
(
self
,
'day'
,
None
)
self
.
baseURL
=
'https
://www.puntomedio.mx/'
+
year
+
'/'
+
month
+
'/'
+
day
self
.
baseURL
=
'http
://www.puntomedio.mx/'
+
year
+
'/'
+
month
+
'/'
+
day
yield
scrapy
.
Request
(
url
=
self
.
baseURL
,
callback
=
self
.
parse
)
...
...
@@ -34,8 +35,8 @@ class QuotesSpider(scrapy.Spider):
for
link
in
response
.
css
(
'div.col-md-8'
)
.
css
(
'h2.title'
)
.
css
(
'a::attr(href)'
)
.
extract
():
yield
scrapy
.
Request
(
url
=
link
,
callback
=
self
.
parse_item
)
next_p
age
=
response
.
css
(
'div.pagination'
)
.
css
(
'a.older-posts::attr(href)'
)
.
extract_first
()
yield
scrapy
.
Request
(
url
=
next_page
,
callback
=
self
.
parse
)
nextP
age
=
response
.
css
(
'div.pagination'
)
.
css
(
'a.older-posts::attr(href)'
)
.
extract_first
()
yield
scrapy
.
Request
(
url
=
nextPage
,
callback
=
self
.
parse
)
def
parse_item
(
self
,
response
):
...
...
@@ -49,12 +50,14 @@ class QuotesSpider(scrapy.Spider):
d
=
d
[:
-
6
]
+
'-06:00'
item
[
'date'
]
=
d
item
[
'topic'
]
=
response
.
xpath
(
'//a[@rel="category tag"]
/text()'
)
.
extract_first
()
item
[
'topic'
]
=
response
.
xpath
(
'//ul[@class="post-categories"]/li/a
/text()'
)
.
extract_first
()
for
paragraph
in
response
.
css
(
'div.post-entry'
)
.
css
(
'p'
)
.
extract
():
text
+=
remove_tags
(
paragraph
)
for
p
in
response
.
css
(
'div.post-entry'
)
.
css
(
'p'
)
.
extract
():
text
+=
remove_tags
(
p
)
item
[
'text'
]
=
text
item
[
'url'
]
=
response
.
url
# print item['title']
yield
item
descarga_por_dia/puntoMedio/puntoMedio/spiders/noticias.pyc
View file @
7d116982
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