
it.skrape.selects.Selects.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
skrape{it} is a Kotlin-based HTML testing and web scraping library
that can be used seamlessly in both Spring-Boot and other JVM projects.
It places particular emphasis on ease of use, a high level of readability
and attention to performance through the use of non-blocking operations.
The newest version!
package it.skrape.selects
import it.skrape.core.Result
import it.skrape.exceptions.ElementNotFoundException
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
/**
* Will pick the first occurrence of an Element that
* is matching the CSS-Selector.
* @see Overview of CSS-Selectors for further information.
* @param selector that represents an CSS-Selector
* @return Element
*/
@Suppress("MaxLineLength")
infix fun Result.element(selector: String): Element = document.selectFirst(selector) ?: throw ElementNotFoundException(selector)
/**
* shorthand for element
* @param selector that represents an CSS-Selector
* @return Element
* @see element
*/
fun Result.el(selector: String): Element = this.element(selector)
/**
* Will pick all occurrences of an Elements that are matching the CSS-Selector
* and return it as Elements which is basically a List
* @see Overview of CSS-Selectors for further information.
* @param selector that represents an CSS-Selector
* @return Elements
*/
infix fun Result.elements(selector: String): Elements = document.select(selector)
/**
* shorthand for elements
* @param selector that represents an CSS-Selector
* @return Element
* @see elements
*/
fun Result.`$`(selector: String): Elements = document.select(selector)
infix fun Result.header(name: String): String? = this.headers[name]
© 2015 - 2025 Weber Informatics LLC | Privacy Policy