Sign in to follow this  
Followers 0
frostfel

RSS Reader

7 posts in this topic

I made this include to read RSS files. It gets the info you want and returns it in an array. Im sure there are better or more scripts to do this but heres mine:

Heres sample:

This would get all the story titles on Digg

The MsgBox only shows the 1st 5 though

$Test1 = _RSSGetInfo("http://digg.com/rss/index.xml", "<title>", "</title>", 1)
MsgBox(0, "Test", "Title 1: "&$Test1[1]&" Title 2: "&$Test1[2]&" Title 3: "&$Test1[3]&" Title 4: "&$Test1[4]&" Title 5: "&$Test1[5])

If you want to get something else goto the RSS you want to use and view the source then look find what you want say its a description of story find the any description in the source and you should see something like this:

<description>The Linux Foundation has established a new collaborative agreement with Japan's Information Technology Promotion Agency. The two organizations will work together to promote open standards and Linux adoption in Japan.</description>

Notice the <description> and the </description> so in the call do

$Test1 = _RSSGetInfo("http://digg.com/rss/index.xml", "<description>", "</description>")
MsgBox(0, "Test", "Title 1: "&$Test1[1]&" Title 2: "&$Test1[2]&" Title 3: "&$Test1[3]&" Title 4: "&$Test1[4]&" Title 5: "&$Test1[5])

You don't need to put a ", 1)" because that would skip the 1st description which you don't want to do but if you wanted titles the first title would be "Digg" because thats the title of the page and you might not want to include that if you want just story titles

_RSS.au3

#include-once
#region _RSS
; RSS Reader
; Created By: Frostfel
#include <INet.au3>
#include <Array.au3>

; ============================================================================
; Function: _RSSGetInfo($RSS, $RSS_InfoS, $RSS_InfoE[, $RSS_Info_ = 1])
; Description: Gets RSS Info
; Parameter(s): $RSS =  RSS Feed Example: "http://feed.com/index.xml"
;               $RSS_InfoS = String to find for info start Example: <title>
;               $RSS_InfoE = String to find for info end Example: </title>
;               $RSS_Info_Start = [optional] <info>/</info> To start at
;                                   Some RSS feeds will have page titles
;                                   you dont want Defualt = 0
; Requirement(s): None
; Return Value(s): On Success - Returns RSS Info in Array Starting at 1
;                  On Failure - Returns 0
;                       @Error = 1 - Failed to get RSS Feed 
; Author(s): Frostfel
; ============================================================================
Func _RSSGetInfo($RSS, $RSS_InfoS, $RSS_InfoE, $RSS_Info_Start = 0)
$RSSFile = _INetGetSource($RSS)

If @Error Then
    SetError(1)
    Return -1
EndIf

Dim $InfoSearchS = 1
Dim $Info[1000]
Dim $InfoNumA
$InfoNum = $RSS_Info_Start
    While $InfoSearchS <> 6
        $InfoNum += 1
        $InfoNumA += 1
        $InfoSearchS = StringInStr($RSSFile, $RSS_InfoS, 0, $InfoNum)
        $InfoSearchE = StringInStr($RSSFile, $RSS_InfoE, 0, $InfoNum)
        $InfoSearchS += 6
        $InfoSS = StringTrimLeft($RSSFile, $InfoSearchS)
        $InfoSearchE -= 1
        $InfoSE_Len = StringLen(StringTrimLeft($RSSFile, $InfoSearchE))
        $InfoSE = StringTrimRight($InfoSS, $InfoSE_Len)
        _ArrayInsert($Info, $InfoNumA, $InfoSE)
    WEnd
Return $Info
EndFunc
#endregion

Share this post


Link to post
Share on other sites



Thanks, looks very useful....

I feel a RSS UDF coming ? :-)

Share this post


Link to post
Share on other sites

Have you seen _StringBetween() in the help file?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks, this is a great start and has helped me over the hump with an xml related project of my own. Thank!


AutoIt changed my life.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0