简体   繁体   English

特定网站上的Jsoup问题

[英]Jsoup issue on specific website

public class Main extends Activity {

TextView liste1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    new Ara1().execute();

}

public class Ara1 extends AsyncTask<Void,Void,String> {

    ProgressDialog dialog = new ProgressDialog(Main.this);

    @Override
    protected String doInBackground(Void... arg0) {
        // TODO Auto-generated method stub
        int i;
        String result = "";

        try {
            Document document = Jsoup.connect("http://www.bilyoner.com/iddaa/hazir-kupon-detay?yazar=populer").get();
            Elements element = document.select("li.iddaaTabsTab");

            if (element.size() > 0) {
                int x = element.size();

                for (i = 0; i < x ; i++) {
                    result = result + element.get(i).text();
                }

            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return result;
    }

    @Override
    protected void onPostExecute(String result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);

        liste1 = (TextView)findViewById(R.id.tv);
        liste1.setText(result);
        dialog.dismiss();
    }

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
        dialog.setMessage("Aranıyor...");

        dialog.show();
    }

}

When i connect this website " http://www.bilyoner.com/iddaa/hazir-kupon-detay?yazar=populer " and trying to parse, there is a problem that i couldnt get any data. 当我连接此网站“ http://www.bilyoner.com/iddaa/hazir-kupon-detay?yazar=populer ”并尝试解析时,存在我无法获取任何数据的问题。 I tried Jsoup on wikipedia and works great. 我在Wikipedia上尝试了Jsoup,效果很好。

Also when i try this site on try jsoup it seems works without any problem. 另外,当我在尝试jsoup上尝试此站点时,似乎可以正常使用。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Your code is working perfect so it seems it's a problem of your android settings. 您的代码运行完美,因此看来这是您的android设置问题。

there is a problem 有一个问题

Can you give as some more details (eg. stacktrace, error message, ...) about that? 您能否提供更多有关此的详细信息(例如stacktrace,错误消息等)? Without it's realy hard to say whats your problem. 没有它,很难说出您的问题是什么。

Please also read my answers here: Getting table row text from url 也请在这里阅读我的答案: 从url获取表行文本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM