feedex v0.1.4 Feedex

Feedex is a simple elixir feed (atom/rss) parser.

Examples

iex> {:ok, feed} = Feedex.fetch_and_parse "http://9gagrss.com/feed/"
...

iex> {:ok, feed} = Feedex.parse "<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" ..."
...

iex> feed.title
"9GAG RSS feed"

iex> feed.entries |> Enum.map(&(&1.title))
["Are you the lucky one ?", "Hide and Seek", "Playing guitar for little cate", ...]

Results

Feed

  • id feed identifier (usually the site url)
  • title feed title
  • description feed description
  • url feed url
  • site_url feed main site url
  • updated feed last modification timestamp
  • entries entry list

Entry

  • id unique identifier (sha256)
  • title entry title
  • url entry permalink
  • content entry content
  • updated 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

iex> Feedex.fetch_and_parse "http://9gagrss.com/feed/"
%{id: "http://9gagrss.com/", title: "9GAG RSS feed", description: "Free 9GAG RSS feed"...}

iex> Feedex.fetch_and_parse "http://invalid-url"
{:error, :fetch_error}
Link to this function parse(xml, url \\ "")

Parses a xml string.

Examples

iex> Feedex.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> Feedex.parse "foo"
{:error, :invalid_xml}

iex> Feedex.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

iex> Feedex.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> Feedex.parse! "foo"
** (ArgumentError) Not a valid XML