Get the HTML code from loaded WebView [duplicate]

I have something like this

final WebView w=(WebView)findViewById(;

Is there any way to get the html page that is shown in the WebView at some moment of time ? I want to get this html page as string variable.

The point is I want to get the html code after the javascript is executed on a client side...

any guidelines ?



One way I know;

decleration javascript handler in your activity

class LoadListener{
    public void processHTML(String html)

after configure your webview;

webView.addJavascriptInterface(new LoadListener(), "HTMLOUT");

than webview client;

    webView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

                return true;

        public void onPageStarted(WebView view, String url,
                        Bitmap favicon) {

        public void onPageFinished(WebView view, String url) {

One way to get the code is by using the HttpClient as given here. Another solution is given in the following blog.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.