【问题标题】:What is the best way to fetch RSS, in real time or almost实时或几乎实时获取 RSS 的最佳方式是什么
【发布时间】:2010-12-06 02:17:09
【问题描述】:

我想知道什么是实时获取 RSS 提要的最佳方式,而无需下载整个提要,即使它没有更改。 我真的不介意语言,我只是在寻找最好的方法。

【问题讨论】:

    标签: rss real-time feed bandwidth


    【解决方案1】:

    您可以使用ETagIf-Modified-Since header HTTP 标头参数。

    这是一个示例 python 代码:

    etag = ... # etag of previous request
    last_modifier = ... # time of last request
    
    req = urllib2.Request(url)
    if etag:
        req.add_header("If-None-Match", etag)
    
    if last_modified:
        req.add_header("If-Modified-Since", last_modified)
    
    opener = urllib2.build_opener(NotModifiedHandler())
    url_handle = opener.open(req)
    headers = url_handle.info()
    
    if hasattr(url_handle, 'code') and url_handle.code == 304:
        # no change happened
    else:
        # RSS Feed has changed
    

    代码可以转换为任何语言,您只需添加必要的标题标签并检查返回的代码。

    更新:查看此博客条目:HTTP Conditional GET for RSS Hackers

    【讨论】:

      猜你喜欢
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 2017-05-17
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 2021-04-07
      相关资源
      最近更新 更多