Readability is a tool for extracting and curating the primary readable content of a webpage.
Check out The Documentation for full and detailed guides
If available in Hex, the package can be installed as:
- Add readability to your list of dependencies in
mix.exs:
```elixir
def deps do
[{:readability, "~> 0.7"}]
end
```
- Ensure readability is started before your application:
```elixir
def application do
[applications: [:readability]]
end
```
url="https://medium.com/@kenmazaika/why-im-betting-on-elixir-7c8f847b58"summary=Readability.summarize(url)summary.title#=> "Why I’m betting on Elixir"summary.authors#=> ["Ken Mazaika"]summary.article_html#=># <div><div><p id=\"3476\"><strong><em>Background: </em></strong><em>I’ve spent...# ...# ...button!</em></h3></div></div>summary.article_text#=># Background: I’ve spent the past 6 years building web applications in Ruby and.....# ...# ... value in this article, it would mean a lot to me if you hit the recommend button!### Extract the title.Readability.title(html)### Extract authors.Readability.authors(html)### Extract the primary content with transformed html.html|>Readability.article|>Readability.readable_html### Extract only text from the primary content.html|>Readability.article|>Readability.readable_text### you can extract the primary images with Flokihtml|>Readability.article|>Floki.find("img")|>Floki.attribute("src")If result is different with your expectation, you can add options.
url="https://medium.com/@kenmazaika/why-im-betting-on-elixir-7c8f847b58"summary=Readability.summarize(url,[clean_conditionally: false])- min_text_length \\ 25
- remove_unlikely_candidates \\ true
- weight_classes \\ true
- clean_conditionally \\ true
- retry_length \\ 250
You can find other algorithm and regex options in readability.ex
To run the test suite:
$ mix test
- Extract authors
- More configurable
- Summarize function
- Convert relative paths into absolute paths of
img#srcanda#href
Contributions are welcome!
Check out the main features milestone and features of related projects below
- readability.js is a standalone version of the readability library used for Firefox Reader View.
- newspaper is an advanced news extraction, article extraction, and content curation library for Python.
- ruby-readability is a tool for extracting the primary readable content of a webpage.
This code is under the Apache License 2.0. See http://www.apache.org/licenses/LICENSE-2.0.