mardi 25 août 2015

How to retrieve and modify HTML content from WebView with Http Post

i am developing an android app that shows some part of a HTML page.for the first step i use this code provided in question How to retrieve HTML content from WebView.

  • Full html picture

part 1

  • That part i want to show

    part 2

    /* An instance of this class will be registered as a JavaScript interface */
    class MyJavaScriptInterface
    {
        @SuppressWarnings("unused")
        public void processHTML(String html)
        {
            // process the html as needed by the app
        }
    }
    
    final WebView browser = (WebView)findViewById(R.id.browser);
    /* JavaScript must be enabled if you want it to work, obviously */
    browser.getSettings().setJavaScriptEnabled(true);
    
    /* Register a new JavaScript interface called HTMLOUT */
    browser.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
    
    /* WebViewClient must be set BEFORE calling loadUrl! */
    browser.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url)
        {
            /* This call inject JavaScript into the page which just finished loading. */
            browser.loadUrl("javascript:window.HTMLOUT.processHTML('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');");
        }
    });
    
    /* load a web page */
    browser.loadUrl("http://ift.tt/1Id3G3G"); 
    
    

but when a user click on a button in second picture a HTTP post method will be called and this will be the result HTML
enter image description here

my question is how retrieve and modify the Post Result Html before showing to user? and show something like this enter image description here



from Newest questions tagged java - Stack Overflow http://ift.tt/1LyqdzH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire