ElixirRss (elixir_rss v0.2.0)
ElixirRss is a simple feed parser originally meant to parse the feed from crypto news.
examples
Examples
> {:ok, feed} = ElixirRss.fetch_and_parse "https://cointelegraph.com/rss"
...
> {:ok, feed} = ElixirRss.parse "<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" ..."
...
> feed.title
"Cointelegraph.com News"
> feed.entries |> Enum.map(&(&1.title))
["Kazakhstan among top 3 Bitcoin mining destinations after US and China", "3Commas issues security alert as FTX deletes API keys following hack", ...]
results
Results
Feed
id
feed identifier (usually the site url)title
feed titledescription
feed descriptionurl
feed urlsite_url
feed main site urlupdated
feed last modification timestampentries
entry list
Entry
id
unique identifier (sha256)title
entry titleurl
entry permalinkcontent
entry contentimage
url of the thumbnailupdated
entry publication or modification timestamp
Link to this section Summary
Functions
Fetches the given url
and parses the response using parse/2
.
Parses a xml
string.
Similar to parse/2
but raises ArgumentError
if unable to parse the xml
.
Link to this section Functions
Link to this function
fetch_and_parse(url)
Fetches the given url
and parses the response using parse/2
.
examples
Examples
iex> ElixirRss.fetch_and_parse "http://9gagrss.com/feed/"
%{id: "http://9gagrss.com/", title: "9GAG RSS feed", description: "Free 9GAG RSS feed"...}
iex> ElixirRss.fetch_and_parse "http://invalid-url"
{:error, :fetch_error}
Link to this function
parse(xml, url \\ "")
Parses a xml
string.
examples
Examples
iex> ElixirRss.parse "<rss version="2.0"><channel><title>9GAG RSS feed</title><description>Free 9GAG RSS feed</description>..."
{:ok, %{id: "http://9gagrss.com/", title: "9GAG RSS feed", description: "Free 9GAG RSS feed"...}}
iex> ElixirRss.parse "foo"
{:error, :invalid_xml}
iex> ElixirRss.parse("<!DOCTYPE html><html lang="en"><head><meta charset...")
{:error, :unknown_feed_format}
Link to this function
parse!(xml, url \\ "")
Similar to parse/2
but raises ArgumentError
if unable to parse the xml
.
examples
Examples
iex> ElixirRss.parse! "<rss version="2.0"><channel><title>9GAG RSS feed</title><description>Free 9GAG RSS feed</description>..."
{:ok, %{id: "http://9gagrss.com/", title: "9GAG RSS feed", description: "Free 9GAG RSS feed"...}}
iex> ElixirRss.parse! "foo"
** (ArgumentError) Not a valid XML