scrape v2.0.0 Scrape.Exquery

A minimal abstraction to have basic selectors working similar to jQuery. Getters are enough for now, setters are irrelevant for scraping. Also the HTML nodes itself are unimportant, only the actual content matters.

Summary

Functions

Find all matching HTML elements and return the values of the chosen attribute as a list of strings. The result list can then be filtered via the last parameter, which refers to the functions of the Scrape.Filter, default is :longest. Filtering works similar to find/3

Find all matching HTML elements and extract their textual contents into a list of raw strings. The result list can then be filtered via the last parameter, which refers to the functions of the Scrape.Filter, default is :longest

Functions

attr(html, selector, name, filter \\ :longest)
attr(String.t, String.t, String.t, atom) :: [String.t]

Find all matching HTML elements and return the values of the chosen attribute as a list of strings. The result list can then be filtered via the last parameter, which refers to the functions of the Scrape.Filter, default is :longest. Filtering works similar to find/3.

## Example

iex> Scrape.Exquery.attr "<a href='ab'><a><a href='ab'></a>","a","href"
  "ab"
find(html, selector, filter \\ :longest)
find(String.t, String.t, atom) :: [String.t]

Find all matching HTML elements and extract their textual contents into a list of raw strings. The result list can then be filtered via the last parameter, which refers to the functions of the Scrape.Filter, default is :longest.

## Example

iex> Scrape.Exquery.find("<p><i>abc</i><i>abcd</i></p>", "i")
  "abcd"

  iex> Scrape.Exquery.find("<p><i>abc</i><i>abcd</i></p>", "i", :first)
  "abc"

  iex> Scrape.Exquery.find("<p><i>abc</i><i>abcd</i></p>", "i", :all)
  ["abc", "abcd"]