Package-level declarations

Types

Link copied to clipboard
class Document

Represents an HTML document.

Link copied to clipboard
class Element

Represents an HTML element.

Properties

Link copied to clipboard
actual val engine: HttpClientEngine
actual val engine: HttpClientEngine
actual val engine: HttpClientEngine
actual val engine: HttpClientEngine
actual val engine: HttpClientEngine

Functions

Link copied to clipboard

Clears the document cache.

Link copied to clipboard

Closes the client. This should be called when the API is no longer needed.

Link copied to clipboard
suspend fun fetch(url: String, request: HttpRequestBuilder.() -> Unit = {}): Document

Fetches a document from the given URL.

Link copied to clipboard
suspend fun String.fetchBytes(request: HttpRequestBuilder.() -> Unit = {}): ByteArray

Fetches the bytes from the given URL.

Link copied to clipboard
suspend fun String.fetchBytesOrNull(request: HttpRequestBuilder.() -> Unit = {}): ByteArray?

Fetches the bytes from the given URL, returning null if an error occurs.

Link copied to clipboard
suspend fun String.fetchDocument(request: HttpRequestBuilder.() -> Unit = {}): Document

Fetches a document from the given URL.

Link copied to clipboard
suspend fun String.fetchDocumentOrNull(request: HttpRequestBuilder.() -> Unit = {}): Document?

Fetches a document from the given URL, returning null if an error occurs.

Link copied to clipboard
suspend fun String.fetchText(request: HttpRequestBuilder.() -> Unit = {}): String

Fetches the text content from the given URL.

Link copied to clipboard
suspend fun String.fetchTextOrNull(request: HttpRequestBuilder.() -> Unit = {}): String?

Fetches the text content from the given URL, returning null if an error occurs.

Link copied to clipboard

Gets the full text content of the document's body.

Link copied to clipboard

Gets the canonical URL of the document based on the <link rel="canonical"> tag.

Link copied to clipboard

Gets the charset of the document based on the <meta charset> or <meta http-equiv="Content-Type"> tag.

Link copied to clipboard

Gets the description of the document based on the <meta name="description"> tag.

Link copied to clipboard

Gets the first element with the specified ID.

Gets the first element with the specified ID within the element.

Link copied to clipboard

Gets all elements with the specified class name.

Gets all elements with the specified class name within the element.

Link copied to clipboard

Gets the favicon URL from the document. This checks for common favicon link types such as:

Link copied to clipboard

Gets the icon links from the document. This includes both <link rel="icon"> and <link rel="shortcut icon">.

Link copied to clipboard

Gets the language of the document. This checks for the <html lang="..."> attribute first, then falls back to the <meta http-equiv="Content-Language"> tag.

Link copied to clipboard

Gets the main text content of the document. This is typically the content inside the <main> tag or the body if no main tag exists.

Link copied to clipboard

Gets the Open Graph metadata from the document.

Link copied to clipboard

Gets the stylesheets linked in the document. This includes <link rel='stylesheet'> tags.

Link copied to clipboard

Gets the title of the document.

Link copied to clipboard

Gets the Twitter Card metadata from the document.

Link copied to clipboard

Gets the viewport settings of the document based on the <meta name="viewport"> tag.

Link copied to clipboard

Gets the value of an input element.

Gets the value of an input element within the element.

Link copied to clipboard
fun Document.querySelector(selector: String, filter: (Element) -> Boolean = { true }): Element?

Gets the first element that matches the specified CSS selector.

fun Element.querySelector(selector: String, filter: (Element) -> Boolean = { true }): Element?

Gets the first element that matches the specified CSS selector within the element.

Link copied to clipboard
actual fun Document.querySelectorAll(selector: String): List<Element>
actual fun Element.querySelectorAll(selector: String): List<Element>
actual fun Document.querySelectorAll(selector: String): List<Element>
actual fun Document.querySelectorAll(selector: String): List<Element>
actual fun Element.querySelectorAll(selector: String): List<Element>
actual fun Element.querySelectorAll(selector: String): List<Element>
expect fun Document.querySelectorAll(selector: String): List<Element>

Gets all elements that match the specified CSS selector.

expect fun Element.querySelectorAll(selector: String): List<Element>

Gets all elements that match the specified CSS selector within the element.

actual fun Document.querySelectorAll(selector: String): List<Element>
actual fun Element.querySelectorAll(selector: String): List<Element>
actual fun Document.querySelectorAll(selector: String): List<Element>
actual fun Element.querySelectorAll(selector: String): List<Element>
actual fun Document.querySelectorAll(selector: String): List<Element>
actual fun Element.querySelectorAll(selector: String): List<Element>
Link copied to clipboard
fun <T> Document.transformClassName(className: String, transformer: (List<Element>) -> T): T

Transforms a class name into an object.

Link copied to clipboard
fun <T> Document.transformId(id: String, transformer: (Element) -> T): T

Transforms an ID into an object.

Link copied to clipboard
fun <T> Document.transformQuerySelector(selector: String, transformer: (Element) -> T): T

Transforms a query selector into an object.

Link copied to clipboard
fun <T> Document.transformQuerySelectorAll(selector: String, transformer: (List<Element>) -> T): T

Transforms a query selector into an object.