Crawl HTML data from an EngineSession

95 views Asked by At

In my Android app, I use an EngineSession (rendered by an EngineView) to display data. In actual fact, this data is plain JSON. Is there a way I can crawl/scrape the HTML directly from the EngineSession so that I can have access to the JSON being returned?

If I was using a WebView, I could have used WebView's evaluateJavascript() function.

The only EngineSession functions I can see that can potentially export the HTML data are:

  • requestPdfToDownload()
  • requestPrintContent()

But neither of these functions gives direct access to the raw HTML being displayed. How can I go about this?

I would appreciate any help or pointers.

1

There are 1 answers

5
ΓDΛ On

I did some research. then webview deployment was noticed in the following situation.

It is loaded into the relevant webView.

override fun render(session: EngineSession) {
        val internalSession = session as SystemEngineSession
        this.session = internalSession

        internalSession.view = WeakReference(this)
        internalSession.initSettings()

        internalSession.scheduledLoad.data?.let {
             // it -> string html
            currentWebView.loadData(it, internalSession.scheduledLoad.mimeType, "UTF-8")
            internalSession.scheduledLoad = ScheduledLoad()
        }

        internalSession.scheduledLoad.url?.let {
            currentWebView.loadUrl(it, additionalHeaders)
            internalSession.scheduledLoad = ScheduledLoad()
        }
    }

If you can access the engineSession. you can use

val internalSession = session as SystemEngineSession
var data = internalSession.scheduledLoad.data