View Source Crawler.Snapper.LinkReplacer (Crawler v1.5.0)
Replaces links found in a page so they work offline.
Summary
Functions
Replaces links found in a page so they work offline.
Functions
Replaces links found in a page so they work offline.
Examples
iex> LinkReplacer.replace_links(
iex> "<a href='http://another.domain/page.html'></a>",
iex> %{
iex> url: "http://main.domain/dir/page",
iex> depth: 1,
iex> max_depths: 2,
iex> html_tag: "a",
iex> content_type: "text/html",
iex> }
iex> )
{:ok, "<a href='../../../another.domain/page.html'></a>"}
iex> LinkReplacer.replace_links(
iex> "<a href='http://another.domain/dir/page.html'></a>",
iex> %{
iex> url: "http://main.domain/page",
iex> depth: 1,
iex> max_depths: 2,
iex> html_tag: "a",
iex> content_type: "text/html",
iex> }
iex> )
{:ok, "<a href='../../another.domain/dir/page.html'></a>"}
iex> LinkReplacer.replace_links(
iex> "<a href='http://another.domain/dir/page'></a>",
iex> %{
iex> url: "http://main.domain/dir/page",
iex> depth: 1,
iex> max_depths: 2,
iex> html_tag: "a",
iex> content_type: "text/html",
iex> }
iex> )
{:ok, "<a href='../../../another.domain/dir/page/index.html'></a>"}
iex> LinkReplacer.replace_links(
iex> "<a href='/dir/page2.html'></a>",
iex> %{
iex> url: "http://main.domain/dir/page",
iex> referrer_url: "http://main.domain/dir/page",
iex> depth: 1,
iex> max_depths: 2,
iex> html_tag: "a",
iex> content_type: "text/html",
iex> }
iex> )
{:ok, "<a href='../../../main.domain/dir/page2.html'></a>"}