Extract HTML from a WebView
I want to extract only the Table (TagName: tbody) from the following Webpage: http://info.tam.ch/custom/stpl_klw.php
But it doesn't work. Can somebody help me?
(I used this Tutorial: http://lexandera.com/2009/01/extracting-html-from-a-webview/)
I tried this:
public class Stundenplan extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Context myApp = this;
class MyJavaScriptInterface
{
@SuppressWarnings("unused")
public void showHTML(String html)
{
new AlertDialog.Builder(myApp)
.setTitle("HTML")
.setMessage(html)
.setPositiveButton(android.R.string.ok, null)
.setCancelable(false)
.create()
.show();
}
}
final WebView browser = (WebView)findViewById(R.id.webView);
browser.getSettings().setJavaScriptEnabled(true);
browser.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
browser.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url)
{
browser.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('tbody')[0].innerHTML+'</head>');");
}
});
browser.loadUrl("http开发者_Python百科://info.tam.ch/custom/stpl_klw.php");
}
The html of the referenced page does not contain a <tbody>
element. The Stundenplan is a normal <table>
element.
精彩评论