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
349869d9
Commit
349869d9
authored
Oct 07, 2019
by
Mudada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Super ugly inline-js parsing
parent
a8a0f838
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
SEARX.hs
src/SEARX.hs
+27
-5
No files found.
src/SEARX.hs
View file @
349869d9
...
@@ -21,6 +21,8 @@ import SEARX.Client
...
@@ -21,6 +21,8 @@ import SEARX.Client
import
Data.Foldable
import
Data.Foldable
import
qualified
Data.Text
as
T
import
qualified
Data.Text
as
T
import
Data.Aeson
import
GHC.Generics
{-
{-
debug purpose, use getMetadataWith
debug purpose, use getMetadataWith
...
@@ -37,19 +39,39 @@ getMetadataWith2 q = do
...
@@ -37,19 +39,39 @@ getMetadataWith2 q = do
// Title
// Title
article.close();
article.close();
-}
-}
parseWebsite
::
T
.
Text
->
IO
Int
data
Article
=
Article
{
title
::
Maybe
T
.
Text
,
byline
::
Maybe
T
.
Text
,
dir
::
Maybe
T
.
Text
,
content
::
Maybe
T
.
Text
,
textContent
::
Maybe
T
.
Text
,
length
::
Maybe
Int
,
excerpt
::
Maybe
T
.
Text
,
siteName
::
Maybe
T
.
Text
}
deriving
(
Generic
,
Show
,
FromJSON
,
ToJSON
)
parseWebsite
::
T
.
Text
->
IO
Article
parseWebsite
url
=
parseWebsite
url
=
withSystemTempDirectory
""
$
\
tmpdir
->
do
withSystemTempDirectory
""
$
\
tmpdir
->
do
withCurrentDirectory
tmpdir
$
withCurrentDirectory
tmpdir
$
traverse_
traverse_
callCommand
callCommand
[
"npm init --yes"
,
"npm install --save node-readability"
]
[
"npm init --yes"
,
"npm install --save jsdom request-promise-native"
,
"git clone https://github.com/mozilla/readability.git"
]
withJSSession
withJSSession
defJSSessionOpts
{
nodeWorkDir
=
Just
tmpdir
}
defJSSessionOpts
{
nodeWorkDir
=
Just
tmpdir
}
[
block
|
[
block
|
return 12;
var {JSDOM} = require('jsdom');
});
var rp = require('request-promise-native');
|]
var Readability = require('./readability');
const val = await rp($url);
const doc = new JSDOM(val, {url: $url})
const reader = new Readability(doc.window.document);
const article = reader.parse();
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