Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
istex
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
crawlers
istex
Commits
6f60c2a4
Commit
6f60c2a4
authored
Aug 28, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
ssh://gitlab.iscpif.fr:20022/gargantext/crawlers/istex
parents
38f62025
1849d1c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
14 deletions
+59
-14
.gitignore
.gitignore
+3
-0
Main.hs
app/Main.hs
+5
-3
ISTEX.hs
src/ISTEX.hs
+12
-0
Client.hs
src/ISTEX/Client.hs
+39
-11
No files found.
.gitignore
0 → 100644
View file @
6f60c2a4
.stack-work/
crawlerISTEX.cabal
*~
\ No newline at end of file
app/Main.hs
View file @
6f60c2a4
...
...
@@ -7,7 +7,9 @@ import ISTEX.Client
main
::
IO
()
main
=
do
res
<-
runIstexAPIClient
$
search
(
Just
40
)
(
Just
"ia"
)
(
Just
"author,title
"
)
res
<-
basicSearch
(
Just
"ia
"
)
case
res
of
(
Left
err
)
->
print
err
(
Right
val
)
->
print
val
(
Left
err
)
->
print
"Error"
(
Right
val
)
->
do
print
$
take
5
$
_hits
val
-- print $ _abstract <$> (_hits val)
src/ISTEX.hs
View file @
6f60c2a4
{-# LANGUAGE OverloadedStrings #-}
module
ISTEX
where
import
ISTEX.Client
...
...
@@ -5,7 +7,17 @@ import Network.HTTP.Client (newManager)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Servant.Client
import
qualified
Data.Text
as
T
runIstexAPIClient
::
ClientM
(
Documents
)
->
IO
(
Either
ClientError
Documents
)
runIstexAPIClient
cmd
=
do
manager'
<-
newManager
tlsManagerSettings
runClientM
cmd
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.istex.fr"
443
"document"
)
basicSearch
::
Maybe
T
.
Text
->
IO
(
Either
ClientError
Documents
)
basicSearch
rq
=
do
runIstexAPIClient
$
search
(
Just
"author,title,abstract,publicationDate,refBibs"
)
(
Just
5000
)
rq
src/ISTEX/Client.hs
View file @
6f60c2a4
...
...
@@ -19,30 +19,57 @@ import qualified Control.Lens as L
data
Author
=
Author
{
_name
::
T
.
Text
,
_affiliations
::
[
T
.
Text
]
_
author_
name
::
T
.
Text
,
_a
uthor_a
ffiliations
::
[
T
.
Text
]
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
A
uthor
instance
FromJSON
Author
where
parseJSON
(
Object
o
)
=
Author
<$>
(
o
.:
"name"
)
<*>
(
o
.:
"affiliations"
<|>
pure
[]
)
data
Source
=
Source
{
_source_title
::
Maybe
T
.
Text
,
_source_authors
::
[
Author
],
_source_publicationDate
::
Maybe
Int
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
S
ource
instance
FromJSON
Source
where
parseJSON
(
Object
o
)
=
Source
<$>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
data
Document
=
Document
{
_id
::
T
.
Text
,
_title
::
Maybe
T
.
Text
,
_authors
::
[
Author
]
_document_id
::
T
.
Text
,
_document_title
::
Maybe
T
.
Text
,
_document_authors
::
[
Author
],
_document_abstract
::
Maybe
T
.
Text
,
_document_publicationDate
::
Maybe
Int
,
_document_sources
::
[
Source
]
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocument
instance
FromJSON
Document
where
parseJSON
(
Object
o
)
=
Document
<$>
(
o
.:
"id"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
Document
<$>
(
o
.:
"id"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
<*>
(
o
.:?
"abstract"
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
<*>
(
o
.:
"refBibs"
<|>
pure
[]
)
data
Documents
=
Documents
{
_total
::
Int
,
_hits
::
[
Document
]
_
documents_
total
::
Int
,
_
documents_
hits
::
[
Document
]
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocuments
instance
FromJSON
Documents
where
...
...
@@ -51,13 +78,14 @@ instance FromJSON Documents where
type
ISTEXAPI
=
Search
type
Search
=
QueryParam
"size"
Int
type
Search
=
QueryParam
"output"
T
.
Text
:>
QueryParam
"size"
Int
:>
QueryParam
"q"
T
.
Text
:>
QueryParam
"output"
T
.
Text
:>
Get
'[
J
SON
]
Documents
istexProxy
::
Proxy
(
ISTEXAPI
)
istexProxy
=
Proxy
search
::
Maybe
Int
->
Maybe
T
.
Tex
t
->
Maybe
T
.
Text
->
ClientM
Documents
search
::
Maybe
T
.
Text
->
Maybe
In
t
->
Maybe
T
.
Text
->
ClientM
Documents
search
=
client
istexProxy
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