2

I am encountering a problem where I need to get the specific content of a webpage into my webview. Here is the webpage I want to get the content from here.

But I only want to get the specific content in that webpage, like shown below:

extracted part

I don't know JavaScript, CSS, or HTML, so I don't know how to extract information. I've checked all over Google, but nothing solves the problem. Can someone post the code of how to do this? Thanks, any help is greatly appreciated.

phadej
  • 11,947
  • 41
  • 78
user2507301
  • 153
  • 1
  • 15

2 Answers2

2

You can check this : Android WebView: display only some part of website

Here, you just have to hide 3 divs : #gb, #appbar, #gf-nav.

For your WebClient :

@Override
public void onPageFinished(WebView view, String url) {
    StringBuilder builder = new StringBuilder("");
    builder.append("javascript:document.getElementById('gb')    .style.visibility= 'hidden';");
    builder.append("javascript:document.getElementById('gb')    .style.display   = 'none'  ;");
    builder.append("javascript:document.getElementById('appbar').style.visibility= 'hidden';");
    builder.append("javascript:document.getElementById('appbar').style.display   = 'none'  ;");
    builder.append("javascript:document.getElementById('gf-nav').style.visibility= 'hidden';");
    builder.append("javascript:document.getElementById('gf-nav').style.display   = 'none'  ;");

    view.loadUrl(builder.toString());
}

I haven't tested it but it should work.

Community
  • 1
  • 1
kmas
  • 6,401
  • 13
  • 40
  • 62
0

Well this is not that simple, the short answer:

You need to download the webpage using an AsyncTask which will potentially give you a string object containing the HTML code, then you would need to parse that string and get the content you need and build a new string containing the new HTML code which then you would output on your webview.

Sorry but the question is just too broad, that is the basic idea though.

ah008a
  • 1,115
  • 6
  • 11