Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pubmed
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
pubmed
Commits
0b906ccc
Commit
0b906ccc
authored
Sep 07, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Adding a threadelay to not be banned
parent
02e03d9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
PUBMED.hs
src/PUBMED.hs
+6
-3
No files found.
src/PUBMED.hs
View file @
0b906ccc
...
...
@@ -2,6 +2,7 @@ module PUBMED where
import
Conduit
import
Control.Applicative
import
Control.Concurrent
(
threadDelay
)
import
Data.Attoparsec.ByteString
import
Data.Attoparsec.ByteString.Char8
(
anyChar
)
import
Data.ByteString.Char8
(
pack
)
...
...
@@ -10,9 +11,9 @@ import Data.Maybe (fromMaybe)
import
Data.Text
(
Text
)
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Panic
(
panic
)
import
PUBMED.Client
import
PUBMED.Parser
import
Panic
(
panic
)
import
Prelude
hiding
(
takeWhile
)
import
Servant.Client
(
runClientM
,
mkClientEnv
,
BaseUrl
(
..
),
ClientEnv
,
ClientError
,
Scheme
(
..
))
import
qualified
Data.ByteString.Lazy
as
LBS
...
...
@@ -61,9 +62,11 @@ getPage :: ClientEnv -> Text -> Int -> Int -> IO [PubMed]
getPage
env
q
perPage
pageNum
=
do
let
offset
=
fromIntegral
$
pageNum
*
perPage
eDocs
<-
runSimpleFindPubmedAbstractRequest
q
(
Just
offset
)
(
Just
$
fromIntegral
perPage
)
pure
$
case
eDocs
of
case
eDocs
of
Left
err
->
panic
$
"[getPage] error: "
<>
show
err
Right
docs
->
docs
Right
docs
->
do
_
<-
threadDelay
1000000
-- One seconds
pure
docs
-- | TODO this parser need at least one subs at the end
-- (use endOfInput)
...
...
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