解析网页链接返回"您正被重定向..."

时间:2017-11-04 18:19:19

标签: java android jsoup

我正在尝试使用jsoup

解析来自以下网站https://consolecrunch.com/的所有链接
    public void GetLinks(final String p0)
    {
        new Thread(new Runnable()
            {
                @Override
                public void run()
                {
                    final StringBuilder builder = new StringBuilder();
                    try
                    {
                        Document doc = Jsoup.connect(p0).get();
                        String title = doc.title();
                        Elements links = doc.select("a[href]");

                        builder.append(title).append("\n");

                        for (Element link : links)
                        {
                            Log.d("LINK", builder.append("\n").append("Link : ").append(link.attr("href"))
                                  .append("\n").append("Text : ").append(link.text()).toString());
                        }
                    }
                    catch (Exception e)
                    {
                        Log.d("EXCEPTION", e.toString());
                    }
                    runOnUiThread(new Runnable()
                        {
                            @Override
                            public void run()
                            {
                                result.setText(builder.toString());
                            }
                        });
                }

            }).start();
    }
}

它总是返回"你被重定向......" 我怎样才能通过重定向? 我试过了 followredirects(真) 和 followredirects(假)

0 个答案:

没有答案