jvmAndroidCommonMain.com.fleeksoft.ksoup.KsoupJvmExt.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ksoup-jvm Show documentation
Show all versions of ksoup-jvm Show documentation
Ksoup is a Kotlin Multiplatform library for working with HTML and XML, and offers an easy-to-use API for URL fetching, data parsing, extraction, and manipulation using DOM and CSS selectors.
The newest version!
package com.fleeksoft.ksoup
import com.fleeksoft.ksoup.nodes.Document
import com.fleeksoft.ksoup.parser.Parser
import com.fleeksoft.ksoup.ported.BufferReader
import okio.source
import java.io.InputStream
/**
* Parse the contents of a file as HTML.
*
* @param inputStream input stream to read.
* @param charsetName (optional) character set of file contents. Set to `null` to determine from `http-equiv` meta tag, if
* present, or fall back to `UTF-8` (which is often safe to do).
* @param baseUri The URL where the HTML was retrieved from, to resolve relative links against.
* @return sane HTML
*/
public fun Ksoup.parseInputStream(
inputStream: InputStream,
baseUri: String,
charsetName: String? = null,
parser: Parser = Parser.htmlParser(),
): Document {
return parse(
bufferReader = BufferReader(source = inputStream.source()),
charsetName = charsetName,
baseUri = baseUri,
parser = parser,
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy