Meeseeks v0.1.0 Meeseeks
# Fetch HTML with your preferred library
html = Tesla.get("https://news.ycombinator.com/").body
# Select stories and return a map containing the title and url of each
for story <- Meeseeks.all(html, "tr.athing") do
title_a = Meeseeks.one(story, ".title a")
%{:title => Meeseeks.text(title_a),
:url => Meeseeks.attr(title_a, "href")}
end
#=> [%{:title => "...", :url => "..."}, %{:title => "...", :url => "..."}, ...]
Summary
Functions
Returns a Result
for each node in the queryable matching a selector
Returns Result
’s value for the attribute or nil
Returns Result
’s attribute vector or nil
Returns the combined data (contents of script and style tags) of Result
and its children, which may be an empty string
Returns a Result
for the first node in the queryable (depth-first) matching a selector
Parses a source (HTML string or tuple-tree) into a Document
Returns Result
’s tag or nil
Returns the combined text of Result
and its children, which may be an empty string
Returns a tuple-tree representing Result
and its children
Types
Functions
Returns a Result
for each node in the queryable matching a selector.
Examples
iex> Meeseeks.all("<div id=main><p>1</p><p>2</p><p>3</p></div>", "#main p")
[%Meeseeks.Result{...}, %Meeseeks.Result{...}, %Meeseeks.Result{...}]
Returns Result
’s value for the attribute or nil.
Examples
iex> result = Meeseeks.one("<div id=example>Hi</div>", "#example")
%Meeseeks.Result{...}
iex> Meeseeks.attr(result, "id")
"example"
Returns Result
’s attribute vector or nil.
Examples
iex> result = Meeseeks.one("<div id=example>Hi</div>", "#example")
%Meeseeks.Result{...}
iex> Meeseeks.attrs(result)
[{"id", "example"}]
Returns the combined data (contents of script and style tags) of Result
and its children, which may be an empty string.
Examples
iex> result = Meeseeks.one("<div id=example>Hi</div>", "#example")
%Meeseeks.Result{...}
iex> Meeseeks.data(result)
""
iex> result = Meeseeks.one("<script id=example>Hi</script>", "#example")
%Meeseeks.Result{...}
iex> Meeseeks.data(result)
"Hi"
Returns a Result
for the first node in the queryable (depth-first) matching a selector.
Examples
iex> Meeseeks.one("<div id=main><p>1</p><p>2</p><p>3</p></div>", "#main p")
%Meeseeks.Result{...}
Parses a source (HTML string or tuple-tree) into a Document
.
Examples
iex> Meeseeks.parse("<div id=main><p>Hello, Meeseeks!</p></div>")
%Meeseeks.Document{...}
iex> Meeseeks.parse({"div", [{"id", "main"}], [{"p", [], ["Hello, Meeseeks!"]}]})
%Meeseeks.Document{...}
Returns Result
’s tag or nil.
Examples
iex> result = Meeseeks.one("<div id=example>Hi</div>", "#example")
%Meeseeks.Result{...}
iex> Meeseeks.tag(result)
"div"
Returns the combined text of Result
and its children, which may be an empty string.
Examples
iex> result = Meeseeks.one("<div id=example>Hi</div>", "#example")
%Meeseeks.Result{...}
iex> Meeseeks.text(result)
"Hi"