Android - 如何从.net网站解析RSS Feed?

时间:2012-11-30 16:15:52

标签: android rss dotnetnuke jsoup

我正在使用此方法从URL读取RSS源。一切正常,但它无法从.net网络服务器获取资源(例如http://www.dotnetnuke.com/Resources/Blogs/rssid/99.aspx)。

public String getRSSLinkFromURL(String url) {
// RSS url
    String rss_url = null;

    try {
    // Using JSoup library to parse the html source code
    org.jsoup.nodes.Document doc = Jsoup.connect(url).get();
    // finding rss links which are having link[type=application/rss+xml]
    org.jsoup.select.Elements links = doc.select("link[type=application/rss+xml]");

    Log.d("No of RSS links found", " " + links.size());

    // check if urls found or not
    if (links.size() > 0) {
        rss_url = links.get(0).attr("href").toString();
    } else {
        // finding rss links which are having link[type=application/rss+xml]
        org.jsoup.select.Elements links1 = doc.select("link[type=application/atom+xml]");
        if(links1.size() > 0){
            rss_url = links1.get(0).attr("href").toString();    
        }
    }

    } catch (IOException e) {
    e.printStackTrace();
    }

    // returing RSS url
    return rss_url;
}

1 个答案:

答案 0 :(得分:0)

您的RSS Feed已损坏:传输已关闭但仍有未完成的读取数据

  当套接字关闭之前,

curl将返回该消息   读取大块转移的最终终止块。当然   听起来像是一个服务器错误。

资料来源:[回复:转账已结束,有未完成的读数据,期待:100-继续] [1]

JSoup的修复(解决方法)在这里:

https://github.com/jhy/jsoup/pull/323