JsoupExtensions.kt
vendor/yokan-ext/src/androidMain/kotlin/eu/kanade/tachiyomi/util/JsoupExtensions.kt
1package eu.kanade.tachiyomi.util23import okhttp3.Response4import org.jsoup.Jsoup5import org.jsoup.nodes.Document6import org.jsoup.nodes.Element78fun Element.selectText(9 css: String,10 defaultValue: String? = null,11): String? = select(css).first()?.text() ?: defaultValue1213fun Element.selectInt(14 css: String,15 defaultValue: Int = 0,16): Int = select(css).first()?.text()?.toInt() ?: defaultValue1718fun Element.attrOrText(css: String): String = if (css != "text") attr(css) else text()1920/**21 * Returns a Jsoup document for this response.22 * @param html the body of the response. Use only if the body was read before calling this method.23 */24fun Response.asJsoup(html: String? = null): Document = Jsoup.parse(html ?: body.string(), request.url.toString())25