A dead simple OpenGraph Tags parser for Kotlin, built using Coroutines and Jsoup.
The API is exposed through suspending extension functions.
// In a coroutine scope, or inside runBlocking
val url = URL("https://ogp.me/")
val tags = url.getOpenGraphTags()
println("""
Title: ${tags.title}
Description: ${tags.description}
Locale: ${tags.getProperty("locale")}
""")
The getOpenGraphTags()
method returns a Tags
class which only acts
as a wrapper around the underlying Map<String, List<String>>
object.
Tags
is an inline class, and Inline classes are currently experimental, so make sure you're okay with that before using this library.
The library currently only supports the og:
namespace.
Please feel free to open issues or contribute new features through pull requests.
The library is published on Jitpack. Make sure to add it as a repository to your build.gradle
file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
And then add the library dependency:
dependencies {
implementation "com.github.haroldadmin:opengraphKt:(latest-version)"
}