0

我遇到了无法从网站获取特定内容的问题。我只需要隐藏网站的一部分。

这是网站:

http://www.google.com/finance/company_news?q=CURRENCY%3AUSD&ei=hYbQUcC3LJS80QHnDA

这是我的代码的一部分:

public class WebClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
}

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

private void AddListenerOnButton() {
spinner = (Spinner) getView().findViewById(R.id.spinner);
final WebView webView = (WebView) getView().findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setRenderPriority(RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        String text1 = spinner.getSelectedItem().toString().trim();
        WebClient wc = new WebClient();
        if (text1.equals("US Dollar - USD")) {
            wc.onPageFinished(webView, "http://www.google.com/finance/company_news?q=CURRENCY%3AUSD&ei=hYbQUcC3LJS80QHnDA");
            wc.shouldOverrideUrlLoading(webView, "http://www.google.com/finance/company_news?q=CURRENCY%3AUSD&ei=hYbQUcC3LJS80QHnDA");
        }               
    }

这是我想要的网站的一部分:

http://oi44.tinypic.com/2ilnhwi.jpg

整个网站仍在显示。这里发生了什么?我能做些什么来修复它?任何帮助是极大的赞赏。

4

0 回答 0