1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

用EE的Magpie做个不用更新的网站

本帖由 laogui2006-11-14 发布。版面名称:源码讨论

  1. laogui

    laogui Administrator
    管理成员

    注册:
    2005-08-30
    帖子:
    15,216
    赞:
    35
    我偷百度的科技新闻RSS,列出5条最新的
    代码:
    		{exp:magpie url="http://news.baidu.com/n?cmd=1&class=internet&tn=rss" limit="5" refresh="60"}
    		<ul>
    		{items}
    		<li><a href="{link}">{title}</a></li>
    		{/items}
    		</ul>
    		{/exp:magpie}
    这个插件是基于缓存的,所以不会每次打开都去获取数据,refresh="60"这里是设置多长时间去获取一次最新的新闻,按分钟算的,获取到的数据保存在缓存里,所以平时都是访问本地的数据,不会影响速度

    任何一个网站的RSS都可以,只要RSS里面有的tag就可以调用出来,具体变量可以看下面的说明



    控制面板首页 › 管理 › 其他配置 › 插件管理 › Magpie
    插件信息
    名字 Magpie RSS Parser
    版本 1.3.3
    作者 Paul Burdick
    作者 URL http://www.pmachine.com/
    描述 Retrieves and Parses RSS/Atom Feeds
    Usage
    STEP ONE:
    Insert plugin tag into your template. Set parameters and variables.

    PARAMETERS:
    The tag has three parameters:

    1. url - The URL of the RSS or Atom feed.

    2. limit - Number of items to display from feed.

    3. refresh - How often to refresh the cache file in minutes. The plugin default is to refresh the cached file every three hours.


    Example opening tag: {exp:magpie url="http://www.pmachine.com/news.rss" limit="8" refresh="720"}

    SINGLE VARIABLES:

    feed_version - What version of RSS or Atom is this feed
    feed_type - What type of feed is this, Atom or RSS
    page_url - Page URL of the feed.

    image_title - [RSS] The contents of the &lt;title&gt; element contained within the sub-element &lt;channel&gt;
    image_url - [RSS] The contents of the &lt;url&gt; element contained within the sub-element &lt;channel&gt;
    image_link - [RSS] The contents of the &lt;link&gt; element contained within the sub-element &lt;channel&gt;
    image_description - [RSS] The contents of the optional &lt;description&gt; element contained within the sub-element &lt;channel&gt;
    image_width - [RSS] The contents of the optional &lt;width&gt; element contained within the sub-element &lt;channel&gt;
    image_height - [RSS] The contents of the optional &lt;height&gt; element contained within the sub-element &lt;channel&gt;

    channel_title - [ATOM/RSS-0.91/RSS-1.0/RSS-2.0]
    channel_link - [ATOM/RSS-0.91/RSS-1.0/RSS-2.0]
    channel_modified - [ATOM]
    channel_generator - [ATOM]
    channel_copyright - [ATOM]
    channel_description - [RSS-0.91/ATOM]
    channel_language - [RSS-0.91/RSS-1.0/RSS-2.0]
    channel_pubdate - [RSS-0.91]
    channel_lastbuilddate - [RSS-0.91]
    channel_tagline - [RSS-0.91/RSS-1.0/RSS-2.0]
    channel_creator - [RSS-1.0/RSS-2.0]
    channel_date - [RSS-1.0/RSS-2.0]
    channel_rights - [RSS-2.0]


    PAIR VARIABLES:

    Only one pair variable, {items}, is available, and it is for the entries/items in the RSS/Atom Feeds. This pair
    variable allows many different other single variables to be contained within it depending on the type of feed.

    title - [ATOM/RSS-0.91/RSS-1.0/RSS-2.0]
    link - [ATOM/RSS-0.91/RSS-1.0/RSS-2.0]
    description - [RSS-0.91/RSS-1.0/RSS-2.0]
    about - [RSS-1.0]
    atom_content - [ATOM]
    author_name - [ATOM]
    author_email - [ATOM]
    content - [ATOM/RSS-2.0]
    created - [ATOM]
    creator - [RSS-1.0]
    date - [RSS-2.0]
    description - [ATOM]
    id - [ATOM]
    issued - [ATOM]
    modified - [ATOM]
    subject - [ATOM/RSS-1.0]
    summary - [ATOM/RSS-1.0/RSS-2.0]


    EXAMPLE:

    {exp:magpie url="http://www.pmachine.com/news.xml" limit="10" refresh="720"}
    <ul>
    {items}
    <li><a href="{link}">{title}</a></li>
    {/items}
    </ul>
    {/exp:magpie}


    ***************************
    Version 1.2
    ***************************
    Complete Rewrite That Improved the Caching System Dramatically

    ***************************
    Version 1.2.1 + 1.2.2
    ***************************
    Bug Fixes

    ***************************
    Version 1.2.3
    ***************************
    Modified the code so that one can put 'magpie:' as a prefix on all plugin variables,
    which allows the embedding of this plugin in a {exp:weblog:entries} tag and using
    that tag's variables in this plugin's parameter (url="" parameter, specifically).

    {exp:magpie url="http://www.pmachine.com/news.xml" limit="10" refresh="720"}
    <ul>
    {magpie:items}
    <li><a href="{magpie:link}">{magpie:title}</a></li>
    {/magpie:items}
    </ul>
    {/exp:magpie}

    ***************************
    Version 1.2.4
    ***************************
    Added the ability for the encoding to be parsed out of the XML feed and used to
    convert the feed's data into the encoding specified in the preferences. Requires
    that the Multibyte String (mbstring: http://us4.php.net/manual/en/ref.mbstring.php)
    library be compiled into PHP.

    ***************************
    Version 1.2.5
    ***************************
    Fixed a bug where the Magpie library was adding slashes to the cache directory
    without doing any sort of double slash checking.

    ***************************
    Version 1.3
    ***************************
    Fixed a bug where the channel and image variables were not showing up because of a bug
    introuced in 1.2.

    ***************************
    Version 1.3.1
    ***************************
    New parameter convert_entities="y" which will have any entities in the RSS feed converted
    before being parsed by the PHP XML parser. This is helpful because sometimes the XML
    Parser converts entities incorrectly. You have to empty your Magpie cache after enabling this setting.

    New parameter encoding="ISO-8859-1". Allows you to specify the encoding of the RSS
    feed, which is sometimes helpful when using the convert_encoding="y" parameter.

    ***************************
    Version 1.3.2
    ***************************
    Eliminated all of the darn encoding parameters previously being used and used the
    encoding abilities recently added to the Magpie library that attempts to do all of the
    converting early on.

    ***************************
    Version 1.3.3
    ***************************
    The Snoopy library that is included with the Magpie plugin by default was causing
    problems with the Snoopy library included in the Third Party Linklist module, so
    the name was changed to eliminate the conflict.
     
  2. fen

    fen New Member

    注册:
    2005-12-18
    帖子:
    3,050
    赞:
    25
  3. amio

    amio New Member

    注册:
    2006-06-02
    帖子:
    71
    赞:
    0
    也可以做成几个blogger的共同发布平台
     
  4. srsman

    srsman Active Member

    注册:
    2005-11-08
    帖子:
    1,920
    赞:
    6
    呵呵!淫荡贴!
     
  5. 找不到符号

    找不到符号 New Member

    注册:
    2005-10-29
    帖子:
    308
    赞:
    9
    不用采集的资源积累:)
     
  6. 橘子和狼

    橘子和狼 New Member

    注册:
    2006-09-12
    帖子:
    38
    赞:
    1
    没看懂怎么使用
     
  7. aman.t.o.b

    aman.t.o.b New Member

    注册:
    2006-09-17
    帖子:
    3
    赞:
    0
    能发表到一个分类的条目中吗?一个新闻一个条目。?
     
  8. mycbbs

    mycbbs New Member

    注册:
    2007-01-27
    帖子:
    88
    赞:
    0
    真是不错,好东东
     
  9. swsw007

    swsw007 New Member

    注册:
    2006-07-04
    帖子:
    2,228
    赞:
    1
    老鬼真强:angry:
     
  10. kan108

    kan108 New Member

    注册:
    2005-11-20
    帖子:
    81
    赞:
    3
    这个不错