Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx
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
searx
Commits
3cd592a2
Commit
3cd592a2
authored
Sep 05, 2019
by
Mudada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added possibility to manage the number of page you want
parent
bd7e0e67
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
10 deletions
+31
-10
Main.hs
app/Main.hs
+1
-1
Lib.hs
src/Lib.hs
+0
-6
SEARX.hs
src/SEARX.hs
+25
-3
Client.hs
src/SEARX/Client.hs
+5
-0
No files found.
app/Main.hs
View file @
3cd592a2
...
...
@@ -6,7 +6,7 @@ import SEARX
main
::
IO
()
main
=
do
res
<-
getMetadataWith
"
sociology"
res
<-
getMetadataWith
"
ia"
300
case
res
of
(
Left
err
)
->
print
err
(
Right
r
)
->
print
r
src/Lib.hs
deleted
100644 → 0
View file @
bd7e0e67
module
Lib
(
someFunc
)
where
someFunc
::
IO
()
someFunc
=
putStrLn
"someFunc"
src/SEARX.hs
View file @
3cd592a2
...
...
@@ -11,9 +11,31 @@ import SEARX.Client
import
qualified
Data.Text
as
T
getMetadataWith
::
T
.
Text
->
IO
(
Either
ClientError
Documents
)
getMetadataWith
q
=
do
{-
debug purpose, use getMetadataWith
-}
getMetadataWith2
::
T
.
Text
->
IO
(
Either
ClientError
Documents
)
getMetadataWith2
q
=
do
manager'
<-
newManager
tlsManagerSettings
runClientM
(
search
(
Just
q
)
(
Just
1
)
(
Just
1
)
(
Just
""
)
(
Just
All
)
(
Just
Json
))
(
search
(
Just
q
)
(
Just
1
)
(
Just
3
)
(
Just
""
)
(
Just
All
)
(
Just
Json
))
(
mkClientEnv
manager'
$
BaseUrl
Https
"search.iscpif.fr"
443
""
)
specConcatEith
::
Semigroup
a
=>
Either
b
a
->
Either
b
a
->
Either
b
a
specConcatEith
(
Left
_
)
b
=
b
specConcatEith
a
(
Left
_
)
=
a
specConcatEith
(
Right
a
)
(
Right
b
)
=
Right
$
a
<>
b
getMetadataWith
::
T
.
Text
->
Int
->
IO
(
Either
ClientError
Documents
)
getMetadataWith
q
i
=
do
manager'
<-
newManager
tlsManagerSettings
getMetadataWith'
manager'
q
i
1
where
client'
man
=
mkClientEnv
man
$
BaseUrl
Https
"search.iscpif.fr"
443
""
search'
r'
p'
=
search
(
Just
r'
)
(
Just
1
)
(
Just
p'
)
(
Just
""
)
(
Just
All
)
(
Just
Json
)
getMetadataWith'
man
req
maxP
curP
|
maxP
>=
curP
=
do
val
<-
runClientM
(
search'
req
curP
)
(
client'
man
)
nextVal
<-
getMetadataWith'
man
req
maxP
(
curP
+
1
)
return
$
specConcatEith
val
nextVal
|
otherwise
=
return
(
Right
$
Documents
0
[]
)
src/SEARX/Client.hs
View file @
3cd592a2
...
...
@@ -44,6 +44,11 @@ data Documents = Documents
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocuments
instance
Semigroup
Documents
where
a
<>
b
=
Documents
((
_documents_total
a
)
+
(
_documents_total
b
))
((
_documents_hits
a
)
<>
(
_documents_hits
b
))
instance
FromJSON
Documents
where
parseJSON
(
Object
o
)
=
Documents
<$>
(
o
.:
"number_of_results"
)
<*>
(
o
.:
"results"
)
...
...
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