
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
com.fleeksoft.ksoup:ksoup
Advanced tools
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.
Ksoup is a Kotlin Multiplatform library for working with real-world HTML and XML. It's a port of the renowned Java library, jsoup, and offers an easy-to-use API for URL fetching, data parsing, extraction, and manipulation using DOM and CSS selectors.
The following extension libraries are deprecated and will be removed in a future release:
ksoup-korlibs
(I/O extension)ksoup-network-korlibs
(Network extension)ksoup-network-ktor2
(Network extension)Recommendation:
- For I/O capabilities: Use
ksoup-kotlinx
extension- For network capabilities: Use
ksoup-network
extension (based on Ktor 3)
Ksoup implements the WHATWG HTML5 specification, parsing HTML to the same DOM as modern browsers do, but with support for Android, JVM, and native platforms.
Ksoup is adept at handling all varieties of HTML found in the wild.
Ksoup follows a modular architecture:
com.fleeksoft.ksoup:ksoup
): The main library that provides HTML/XML parsing from stringsInclude the dependencies in your commonMain
. Latest version
Start with the core library. This is all you need if you're only parsing HTML/XML from strings.
// Required core library
implementation("com.fleeksoft.ksoup:ksoup:<version>")
Add one of these extensions only if you need to parse HTML/XML from files or other sources.
Choose one of the following I/O libraries:
kotlinx-io (Recommended)
// Optional: Add this if you need file parsing capabilities
// Provides Ksoup.parseFile, Ksoup.parseSource & Other InputStream APIs
implementation("com.fleeksoft.ksoup:ksoup-kotlinx:<version>")
// Optional: Add this if you need file parsing capabilities
// Provides Ksoup.parseFile, Ksoup.parseSource & Other InputStream APIs
implementation("com.fleeksoft.ksoup:ksoup-okio:<version>")
korlibs-io (DEPRECATED: Use kotlinx-io instead)
// Deprecated: Not recommended for new projects
// Provides Ksoup.parseFile, Ksoup.parseStream & Other InputStream APIs
implementation("com.fleeksoft.ksoup:ksoup-korlibs:<version>")
Add one of these extensions only if you need to fetch and parse HTML/XML directly from URLs.
Choose one of the following network libraries:
Ktor 3 (Recommended)
// Optional: Add this if you need to fetch HTML/XML from URLs
// Provides Ksoup.parseGetRequest, Ksoup.parseSubmitRequest, Ksoup.parsePostRequest
implementation("com.fleeksoft.ksoup:ksoup-network:<version>")
Ktor 2 (DEPRECATED: Use Ktor 3 instead)
// Deprecated: Not recommended for new projects
// Provides Ksoup.parseGetRequest, Ksoup.parseSubmitRequest, Ksoup.parsePostRequest
implementation("com.fleeksoft.ksoup:ksoup-network-ktor2:<version>")
korlibs-io Network (DEPRECATED: Use Ktor 3 instead)
// Deprecated: Not recommended for new projects
// Provides Ksoup.parseGetRequest, Ksoup.parseSubmitRequest, Ksoup.parsePostRequest
implementation("com.fleeksoft.ksoup:ksoup-network-korlibs:<version>")
com.fleeksoft.charset:charset-ext
, For more details, visit the Charsets DocumentationFor API documentation you can check Jsoup. Most of the APIs work without any changes.
val html = "<html><head><title>One</title></head><body>Two</body></html>"
val doc: Document = Ksoup.parse(html = html)
println("title => ${doc.title()}") // One
println("bodyText => ${doc.body().text()}") // Two
This snippet demonstrates how to use Ksoup.parse
for parsing an HTML string and extracting the title and body text.
//Please note that the com.fleeksoft.ksoup:ksoup-network library is required for Ksoup.parseGetRequest.
val doc: Document = Ksoup.parseGetRequest(url = "https://en.wikipedia.org/") // suspend function
// or
val doc: Document = Ksoup.parseGetRequestBlocking(url = "https://en.wikipedia.org/")
println("title: ${doc.title()}")
val headlines: Elements = doc.select("#mp-itn b a")
headlines.forEach { headline: Element ->
val headlineTitle = headline.attr("title")
val headlineLink = headline.absUrl("href")
println("$headlineTitle => $headlineLink")
}
val doc: Document = Ksoup.parse(xml, parser = Parser = Parser.xmlParser())
//Please note that the com.fleeksoft.ksoup:ksoup-network library is required for Ksoup.parseGetRequest.
val doc: Document = Ksoup.parseGetRequest(url = "https://en.wikipedia.org/") // suspend function
val metadata: Metadata = Ksoup.parseMetaData(element = doc) // suspend function
// or
val metadata: Metadata = Ksoup.parseMetaData(html = HTML)
println("title: ${metadata.title}")
println("description: ${metadata.description}")
println("ogTitle: ${metadata.ogTitle}")
println("ogDescription: ${metadata.ogDescription}")
println("twitterTitle: ${metadata.twitterTitle}")
println("twitterDescription: ${metadata.twitterDescription}")
// Check com.fleeksoft.ksoup.model.MetaData for more fields
In this example, Ksoup.parseGetRequest
fetches and parses HTML content from Wikipedia, extracting and printing news headlines and their corresponding links.
Ksoup is an open source project, a Kotlin Multiplatform port of jsoup, distributed under the MIT License, Version 2.0. The source code of Ksoup is available on GitHub.
For questions about usage and general inquiries, please refer to GitHub Discussions.
If you wish to contribute, please read the Contributing Guidelines.
To report any issues, visit our GitHub issues, Please ensure to check for duplicates before submitting a new issue.
Ksoup is open source software licensed under the MIT License.
This project is a Kotlin Multiplatform port of Jsoup, created by Jonathan Hedley.
Portions of this library are derived from jsoup and retain their original MIT License,
© 2009–2025 Jonathan Hedley.
FAQs
Unknown package
We found that com.fleeksoft.ksoup:ksoup demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.