skrapeit / skrape.it

A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion.
https://docs.skrape.it
MIT License
808 stars 59 forks source link

Add android example project #121

Closed christian-draeger closed 3 years ago

christian-draeger commented 3 years ago

We have an examples module. Here we want to showcase possible usages of skrapeit and have a living documentation by example. Therefore we would like to have a small android example project as subfolder of the examples module. It could be something like skrape some data from somewhere and just display it.

This would be nice starting point for the Android devs to use skrapeit.

faogustavo commented 3 years ago

@christian-draeger now we have the android sample :) The PR linking to the repo is already open. After merge we can close this one.

Here is a print of the sample app:

image

Generated form this HTML:

<html>
    <head>
        <title>Hello from HTML</title>
    </head>
    <body>
        <ul>
            <li>first p-element</li>
            <li>some p-element</li>
            <li>last p-element</li>
        </ul>
    </body>
</html>

Parsing with this function:

    fun parse(html: String) {
        val parsedHtml = htmlDocument(html)

        _titleLiveData.postValue(parsedHtml.titleText)
        parsedHtml.findAll("li")
            .map { it.text }
            .let(_itemsLiveData::postValue)
    }
christian-draeger commented 3 years ago

Thx u are awesome :) really big thanks