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
idfeed identifier (usually the site url)titlefeed titledescriptionfeed descriptionurlfeed urlsite_urlfeed main site urlupdatedfeed last modification timestampentriesentry list
Entry
idunique identifier (sha256)titleentry titleurlentry permalinkcontententry contentupdatedentry 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