Skip to content

Instantly share code, notes, and snippets.

@yehgdotnet

yehgdotnet/feed-reader.au3

Last active Aug 25, 2020
Embed
What would you like to do?
AutoIT Feed Reader
Local $feed_file = "theregister.xml"
Local $hDownload = InetGet ( "http://www.theregister.co.uk/security/headlines.atom" , $feed_file )
Local $file = FileOpen($feed_file, 0)
Global $security_feeds = ""
Global $counter = 0
; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
Local $line = FileReadLine($file)
local $nOffset = 1
If @error = -1 Then ExitLoop
; find link
Local $found_link = StringInStr($line, '<link rel="alternate" type="text/html" href="')
If $found_link > 0 Then
Local $lnks = StringRegExp($line, '<link rel="alternate" type="text/html" href="(.*?)"/>', 1, $nOffset)
If UBound($lnks) > 0 Then
Local $lnk = $lnks[0]
$security_feeds = $security_feeds & '<a href="' & $lnk & '">'
Endif
EndIf
; find title
Local $found_title = StringInStr($line, '<title type="html">')
If $found_title > 0 Then
Local $titles = StringRegExp($line, '<title type="html">(.*?)</title>', 1, $nOffset)
if UBound($titles) > 0 then
Local $til = $titles[0]
$security_feeds = $security_feeds & $til & '</a><br>' & @CRLF
endif
$counter = $counter + 1
If $counter > 7 Then
ExitLoop
EndIf
EndIf
WEnd
FileClose($file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment