How To Retrieve The Name And Links Of Every Entry In A RSS Feed?
Description
Rss is becoming more and more popular to share all kind of information. For example this blog has a rss feed that can be found in the following link:
http://www.discoveryourpc.net/feeds/posts/default
I need many times the link of a post so I have to go to my website and navigate it .
Solution
We are going to use Visual Basic Script that come by default in Windows to process the feed and wget to retrieve it.
Let begin.
1. We download wget to c:\utils:
http://users.ugent.be/~bpuype/wget/
2. We save the feed in a file.
a. Press Windows Key + R, type cmd and press enter.
b. In the windows command, type cd /D c:\utils and press enter.
c. Type:
wget -O rss.xml http://www.discoveryourpc.net/feeds/posts/default?format=xml
and press enter.
A new file rss.xml will appear.
3. Now we are going to use a Visual Basic Script, so we need to create it. Open notepad, press Windows Key + R, type notepad and press enter. Copy the following code:
Dim objFSO
pattern = "<title type=’text’>([^<]+)</title>|<link rel=’alternate’ type=’text/html’ href=’([^’]+)’ title"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set file = objFSO.OpenTextFile("c:\\utils\\rss.xml", 1 )
line=""
While not file.AtEndOfStream
line=line & file.ReadLine
Wend
Set procesNameUrl = New RegExp
procesNameUrl.IgnoreCase = True
procesNameUrl.Global = True
procesNameUrl.pattern = pattern
Set matches = procesNameUrl.Execute( line )
For Each match In matches
If match.Submatches(0)<> "" Then
WScript.Echo match.Submatches(0)
End If
If match.Submatches(1)<> "" Then
WScript.Echo match.Submatches(1)
End If
Next
And save it to “processFeed.vbs” don’t forget the quotes so notepad save it as a Visual Basic Script file.
As you can see what this program does is look for the title entry and the link. Regular expressions are a useful tool when you need to process a file.
4. Execute it:
To execute it go to c:\utils folder and type:
cscript processFeed.vbs
Related posts: