HtmlResourceContentIterator

Iterates an HTML resource, starting from the given locator.

If you want to start mid-resource, the locator must contain a cssSelector key in its Locator.Locations object.

If you want to start from the end of the resource, the locator must have a progression of 1.0.

Locators will contain a before context of up to beforeMaxLength characters.

Types

Link copied to clipboard
Link copied to clipboard
data class ParsedElements(val elements: List<Content.Element> = emptyList(), val startIndex: Int = 0)

Holds the result of parsing the HTML resource into a list of Content.Element.

Functions

Link copied to clipboard
open suspend operator override fun hasNext(): Boolean

Returns true if the iterator has a next element, suspending the caller while processing it.

Link copied to clipboard
open suspend override fun hasPrevious(): Boolean

Returns true if the iterator has a previous element, suspending the caller while processing it.

Link copied to clipboard
open operator override fun next(): Content.Element

Retrieves the element computed by a preceding call to hasNext, or throws an IllegalStateException if hasNext was not invoked. This method should only be used in pair with hasNext.

Link copied to clipboard
open suspend fun nextOrNull(): Content.Element?

Advances to the next item and returns it, or null if we reached the end.

Link copied to clipboard
open override fun previous(): Content.Element

Retrieves the element computed by a preceding call to hasPrevious, or throws an IllegalStateException if hasPrevious was not invoked. This method should only be used in pair with hasPrevious.

Link copied to clipboard
open suspend fun previousOrNull(): Content.Element?

Advances to the previous item and returns it, or null if we reached the beginning.