无法从网站获取特定内容

时间:2013-07-03 20:44:36

标签: android

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

这是网站:

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

整个网站仍在展示。这里发生了什么?我该怎么办才能修复它?非常感谢任何帮助。

0 个答案:

没有答案