[英]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 我只想从以下网页中提取表(标记名:tbody): 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/ ) (我使用了本教程: 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://info.tam.ch/custom/stpl_klw.php");
}
The html of the referenced page does not contain a <tbody>
element. 引用页面的html不包含
<tbody>
元素。 The Stundenplan is a normal <table>
element. Stundenplan是一个普通的
<table>
元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.