### Install libgcc on Alpine Docker Images Source: https://github.com/mischov/meeseeks/blob/main/guides/deployment.md Install the libgcc package on Alpine-based Docker images. This is required for the release stage if your Dockerfile separates build and release stages. ```dockerfile RUN apk add --no-cache libgcc ``` -------------------------------- ### Define a Custom Comment Selector Source: https://github.com/mischov/meeseeks/blob/main/guides/custom_selectors.md Implement `Meeseeks.Selector` to create a custom selector that matches comments containing specific text. This example defines `CommentContainsSelector` which checks if a comment's content includes a given value. ```elixir defmodule CommentContainsSelector do use Meeseeks.Selector alias Meeseeks.Document defstruct value: "" def match(selector, %Document.Comment{} = node, _document, _context) do String.contains?(node.content, selector.value) end def match(_selector, _node, _document, _context) do false end end selector = %CommentContainsSelector{value: "TODO"} Meeseeks.one("", selector) #=> #Meeseeks.Result<{ }> ``` -------------------------------- ### Extracting Element Attributes Source: https://github.com/mischov/meeseeks/blob/main/guides/xpath_selectors.md Use the `attr` extractor to get an element's attribute value, such as its class. ```elixir Meeseeks.all(doc, xpath("//p[@class]")) |> Enum.map(&Meeseeks.attr(&1, "class")) ``` -------------------------------- ### Select Node with CSS Source: https://github.com/mischov/meeseeks/blob/main/README.md Selects the first node matching a CSS selector within a document. Ensure Meeseeks.CSS is imported. ```elixir import Meeseeks.CSS result = Meeseeks.one(document, css("#main p")) #=> #Meeseeks.Result<{

1

}> ``` -------------------------------- ### Select Node with XPath Source: https://github.com/mischov/meeseeks/blob/main/README.md Selects the first node matching an XPath query within a document. Ensure Meeseeks.XPath is imported. ```elixir import Meeseeks.XPath result = Meeseeks.one(document, xpath("//*[@id='main']//p")) #=> #Meeseeks.Result<{

1

}> ``` -------------------------------- ### Add Rust Buildpack and Configure Heroku Source: https://github.com/mischov/meeseeks/blob/main/guides/deployment.md Add a Rust buildpack to your Heroku app and set the RUST_SKIP_BUILD environment variable. This ensures Rust is available and configured correctly before the Elixir build. ```bash heroku buildpacks:add -i 1 https://github.com/emk/heroku-buildpack-rust.git echo "RUST_SKIP_BUILD=1" > RustConfig ``` -------------------------------- ### Adding Meeseeks Dependency to Mix Project Source: https://github.com/mischov/meeseeks/blob/main/README.md This code snippet shows how to add the Meeseeks library as a dependency in your Elixir project's `mix.exs` file. After adding this, run `mix deps.get` to fetch the dependency. ```elixir defp deps do [ {:meeseeks, "~> 0.18.0"} ] end ``` -------------------------------- ### Extracting Data from HTML with CSS Selectors Source: https://github.com/mischov/meeseeks/blob/main/README.md This snippet demonstrates how to fetch HTML content and extract specific data points like titles and URLs using Meeseeks with CSS selectors. It requires the HTTPoison library for fetching web content. ```elixir import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do title = Meeseeks.one(story, css(".title a")) %{ title: Meeseeks.text(title), url: Meeseeks.attr(title, "href") } end #=> [%{title: "...", url: "..."}, %{title: "...", url: "..."}, ...] ``` -------------------------------- ### Parse HTML to Document Source: https://github.com/mischov/meeseeks/blob/main/README.md Parses an HTML string into a Meeseeks.Document for querying. Parsing ahead of time is recommended for multiple selections on the same document. ```elixir document = Meeseeks.parse("

1

2

3

") #=> #Meeseeks.Document<{...}> ``` -------------------------------- ### Constructing XPath with Variables Source: https://github.com/mischov/meeseeks/blob/main/guides/xpath_selectors.md When variable references are not supported in XPath, construct the string dynamically using Elixir variables. ```elixir p = 2 xpath("*[position()=" <> Integer.to_string(p) <> "]") ``` -------------------------------- ### Selecting Second List Element Alternative Source: https://github.com/mischov/meeseeks/blob/main/guides/xpath_selectors.md Use this approach to select the second list element when top-level filter expressions are not supported. ```elixir Meeseeks.all(doc, xpath("ol|ul")) |> Enum.at(1) ``` -------------------------------- ### Set RUSTFLAGS for Docker Build Stage Source: https://github.com/mischov/meeseeks/blob/main/guides/deployment.md Set the RUSTFLAGS environment variable during the Docker build stage. This is necessary to prevent compilation failures in mix compile. ```dockerfile RUSTFLAGS='--codegen target-feature=-crt-static' ``` -------------------------------- ### Extract HTML from Document Source: https://github.com/mischov/meeseeks/blob/main/README.md Extracts the entire HTML content of a Meeseeks.Document. ```elixir Meeseeks.html(document) #=> "

1

2

3

" ``` -------------------------------- ### Extract Node Tree Structure Source: https://github.com/mischov/meeseeks/blob/main/README.md Extracts the tree structure of a selected node as a tuple. ```elixir Meeseeks.tree(result) #=> {"p", [], ["1"]} ``` -------------------------------- ### Extract Text Content Source: https://github.com/mischov/meeseeks/blob/main/README.md Extracts the text content of a selected node. ```elixir Meeseeks.text(result) #=> "1" ``` -------------------------------- ### Extract Tag Name Source: https://github.com/mischov/meeseeks/blob/main/README.md Extracts the tag name of a selected node. ```elixir Meeseeks.tag(result) #=> "p" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.