Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
esi-data-scrapping
esi-table-data
Commits
87b3f20f
Commit
87b3f20f
authored
7 years ago
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add freshness news to TechCrunch spider
parent
1d35b5b6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
techcrunch.py
exa/exa/spiders/techcrunch.py
+7
-1
No files found.
exa/exa/spiders/techcrunch.py
View file @
87b3f20f
...
...
@@ -26,6 +26,7 @@ class TechcrunchSpider(BaseSpider):
try
:
news_list
=
response
.
xpath
(
"..//div[contains(@class, 'block block-thumb ')]"
)
company
=
response
.
meta
[
'company'
]
is_duplicate
=
False
for
i
in
news_list
:
item
=
ExaItem
()
item
[
'date'
]
=
i
.
xpath
(
"./div/div/time/@datetime"
)
.
extract_first
()
...
...
@@ -37,11 +38,15 @@ class TechcrunchSpider(BaseSpider):
item
[
'post_id'
]
=
response
.
meta
[
'post_id'
]
if
self
.
pipeline
.
check_url
(
item
[
'url'
]):
is_duplicate
=
True
break
if
item
[
'title'
]:
yield
scrapy
.
Request
(
item
[
'url'
],
callback
=
self
.
parse_tags
,
meta
=
{
'item'
:
item
})
has_next
=
response
.
xpath
(
"//div[contains(@class, 'river-nav')]//li[contains(@class, 'next')]/a/@href"
)
.
extract_first
()
if
has_next
:
if
self
.
can_follow
(
has_next
,
is_duplicate
)
:
next_url
=
'https://techcrunch.com'
+
has_next
+
'/'
yield
scrapy
.
Request
(
next_url
,
callback
=
self
.
parse_tag
,
meta
=
response
.
meta
)
...
...
@@ -65,6 +70,7 @@ class TechcrunchSpider(BaseSpider):
item
.
update
(
self
.
get_common_items
(
company
))
item
[
'post_id'
]
=
response
.
meta
[
'post_id'
]
if
self
.
pipeline
.
check_url
(
item
[
'url'
]):
is_duplicate
=
True
break
...
...
This diff is collapsed.
Click to expand it.
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