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
f0a8c2e6
Commit
f0a8c2e6
authored
Oct 07, 2019
by
Mudada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create / delete directory
parent
a51250b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
Main.hs
app/Main.hs
+5
-2
SEARX.hs
src/SEARX.hs
+25
-16
No files found.
app/Main.hs
View file @
f0a8c2e6
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Main
where
module
Main
where
import
SEARX
import
SEARX
import
System.Directory
main
::
IO
()
main
::
IO
()
main
=
do
main
=
do
...
@@ -10,5 +11,7 @@ main = do
...
@@ -10,5 +11,7 @@ main = do
case
res
of
case
res
of
(
Left
err
)
->
print
err
(
Left
err
)
->
print
err
(
Right
r
)
->
do
(
Right
r
)
->
do
a
<-
parseWebsite
"https://www.lemonde.fr/economie/article/2019/09/23/thomas-cook-semble-se-diriger-vers-une-faillite_6012630_3234.html"
fp
<-
setUpDirectory
print
a
article
<-
parseWebsite
fp
"https://www.lemonde.fr/politique/article/2019/10/07/apres-l-attentat-a-la-prefecture-de-police-christophe-castaner-sous-le-feu-des-critiques_6014514_823448.html"
removeDirectoryRecursive
$
fp
<>
"/readability"
print
article
src/SEARX.hs
View file @
f0a8c2e6
...
@@ -50,26 +50,35 @@ data Article =
...
@@ -50,26 +50,35 @@ data Article =
}
}
deriving
(
Generic
,
Show
,
FromJSON
,
ToJSON
)
deriving
(
Generic
,
Show
,
FromJSON
,
ToJSON
)
parseWebsite
::
T
.
Text
->
IO
Article
setUpDirectory
::
IO
FilePath
parseWebsite
url
=
setUpDirectory
=
withSystemTempDirectory
""
$
\
tmpdir
->
do
do
withCurrentDirectory
tmpdir
$
dir
<-
getCurrentDirectory
_
<-
withCurrentDirectory
dir
$
traverse_
traverse_
callCommand
callCommand
[
"npm init --yes"
,
"npm install --save jsdom request-promise-native"
,
[
"npm init --yes"
"git clone https://github.com/mozilla/readability.git"
]
,
"npm install --save jsdom request-promise-native"
,
"git clone https://github.com/mozilla/readability.git"
]
getCurrentDirectory
parseWebsite
::
FilePath
->
T
.
Text
->
IO
Article
parseWebsite
tmpdir
url
=
do
withJSSession
withJSSession
defJSSessionOpts
{
nodeWorkDir
=
Just
tmpdir
}
defJSSessionOpts
{
nodeWorkDir
=
Just
tmpdir
}
[
block
|
[
block
|
var {JSDOM} = require('jsdom');
var {JSDOM} = require('jsdom');
var rp = require('request-promise-native');
var rp = require('request-promise-native');
var Readability = require('./readability');
var Readability = require('./readability');
const val = await rp($url);
const val = await rp($url);
const doc = new JSDOM(val, {url: $url})
const doc = new JSDOM(val, {url: $url})
const reader = new Readability(doc.window.document);
const reader = new Readability(doc.window.document);
const article = reader.parse();
const article = reader.parse();
return article;
return article;
|]
|]
specConcatEith
::
Semigroup
a
=>
Either
b
a
->
Either
b
a
->
Either
b
a
specConcatEith
::
Semigroup
a
=>
Either
b
a
->
Either
b
a
->
Either
b
a
specConcatEith
(
Left
_
)
b
=
b
specConcatEith
(
Left
_
)
b
=
b
...
...
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