5

Some websites have comments portion and many other unnecessary portions. I want to just display the main article excluding the other portions in my custom Android WebView.

I have tried the example from Display a part of the webpage on the webview android

But it still shows the full website.

There is also the loaddatawithbaseurl class in Android but it is not working too as you can't specify till which portion of a website to show using this class.

Is there any other way to do this?

1 Answer 1

2

Here it is with some changes...

webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { String javaScript = "javascript: var form = document.getElementsByClassName('university_corner');" + "var body = document.getElementsByTagName('div');" + "body[0].innerHTML = form[0].innerHTML"; webView.loadUrl(javaScript); } }); webView.loadUrl(url); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.