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
9e8d051b
Commit
9e8d051b
authored
Jul 10, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functional for take data from DB
parent
7b68057f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
aitop.py
exa/exa/spiders/aitop.py
+22
-0
No files found.
exa/exa/spiders/aitop.py
View file @
9e8d051b
# -*- coding: utf-8 -*-
import
scrapy
import
dateparser
from
scrapy.utils.project
import
get_project_settings
from
..helpers
import
CompanyMaker
,
Database
from
..items
import
ExaItem
db_settings
=
get_project_settings
()
.
get
(
'DB'
)
db
=
Database
(
**
db_settings
)
class
AitopSpider
(
scrapy
.
Spider
):
name
=
"aitop"
allowed_domains
=
[
"aitopics.org"
]
start_urls
=
[
'https://aitopics.org/search?view=&filters=&sort=score+desc&q=x.ai'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
condition
=
kwargs
.
get
(
'query'
)
self
.
query
=
"SELECT id, name, country FROM wp_esi_entity WHERE 1 and id=13"
if
self
.
condition
:
print
(
self
.
condition
)
self
.
query
+=
' or {}'
.
format
(
self
.
condition
)
super
(
AitopSpider
,
self
)
.
__init__
()
def
start_requests
(
self
):
companies
=
CompanyMaker
(
db
.
select
(
self
.
query
))
companies
.
make_companies
(
self
.
name
)
for
i
in
companies
.
get_companies
():
try
:
yield
scrapy
.
Request
(
i
.
url
+
'/'
,
callback
=
self
.
parse
,
meta
=
{
'company'
:
i
,
'post_id'
:
0
})
except
:
pass
def
parse
(
self
,
response
):
name
=
'Uber'
url
=
'https://aitopics.org'
...
...
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