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
e8b3ad9c
Commit
e8b3ad9c
authored
Oct 19, 2017
by
Andrii Marynets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Select field from dict
parent
3249334f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
cb.py
exa/exa/spiders/cb.py
+14
-3
No files found.
exa/exa/spiders/cb.py
View file @
e8b3ad9c
...
...
@@ -46,7 +46,6 @@ class CbSpider(BaseSpider):
pass
def
parse
(
self
,
response
):
print
(
response
.
body
)
body
=
{
"field_ids"
:
[
"activity_properties"
,
...
...
@@ -76,8 +75,10 @@ class CbSpider(BaseSpider):
yield
scrapy
.
Request
(
url
=
'https://www.crunchbase.com/v4/data/searches/activities'
,
method
=
'POST'
,
body
=
json
.
dumps
(
body
),
headers
=
{
'x-requested-with'
:
'XMLHttpRequest'
,
'content-type'
:
'application/json'
},
callback
=
self
.
parse_news
,
meta
=
{
'cookiejar'
:
response
.
meta
[
'cookiejar'
]})
meta
=
{
'cookiejar'
:
response
.
meta
[
'cookiejar'
],
'company'
:
response
.
meta
[
'company'
]})
rows
=
response
.
xpath
(
".//div[@class='grid-body']/div"
)
company
=
response
.
meta
[
'company'
]
...
...
@@ -104,7 +105,17 @@ class CbSpider(BaseSpider):
# if len(rows) != 0 and self.can_follow(next_url, is_duplicate):
# yield scrapy.Request(next_url, callback=self.parse, meta=response.meta)
def
parse_news
(
self
,
response
):
print
(
response
.
body
)
body
=
json
.
loads
(
response
.
body
.
decode
(
'utf8'
))
print
(
body
)
for
i
in
body
[
'entities'
]:
prop
=
i
[
'properties'
]
if
prop
[
'entity_def_id'
]
==
'press_reference'
:
item
=
ExaItem
()
item
[
'date'
]
=
self
.
format_date
(
prop
[
'activity_date'
])
item
[
'title'
]
=
prop
[
'activity_properties'
][
'title'
]
item
[
'url'
]
=
prop
[
'activity_properties'
][
'url'
]
item
.
update
(
self
.
get_common_items
(
response
.
meta
[
'company'
]))
def
_get_media
(
self
,
elem
):
media_name
=
elem
.
xpath
(
"./td[contains(@class, 'article')]/span/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