Hamster-Scripts: Functions (Hamster): RSS/ATOM feeds, Web

RSS/ATOM feeds and Web/WWW related functions

HamWebReader( <feed>, <group>, <subject>, <mode>, <from>, <savefeed> )
HamWebReader( <feed> )

This function loads RSS/XML feeds (version 0.91, 1.0 and 2.0) and ATOM/Blog feeds (version 0.3) into a newsgroup. All files that are not recognized as one of the mentioned formats are treated as being normal HTML files. The generated text out of such files may be readable, but in most cases isn't ...

HamWebReader loads the given <feed> from the internet and converts it to plain text. If the text has changed since it was loaded the last time, it is stored in newsgroup <group> with the given <subject>.

if <group> is missing or empty, the internal group for "unknown newsgroups" is used (internal.misc if not configured differently).

If <subject> is missing or empty, the title of the feed is used as the "Subject:" of the generated message, otherwise the given text is used. If <subject> ends with a star ("[News] *"), the title of the feed is appended to the given text.

Parameter <mode> describes how feed messages are handled (default is 2):

If <from> is missing or empty, author information contained in feed is used for the "From:" header of posted messages (or "webfeed" if feed contains no author information). If <from> is given, this text is used (also supports trailing "*" like <subject>).

If <savefeed> is given and true (1), the raw feed file is stored in subdircetory "rss" of logfile directory (.\logs\rss by default).


Returns: 0=OK/Started, <>0=Not started

See also: How to load RSS and ATOM feeds?

varset( $group, "internal.misc" )

HamWebReader( "http://www.elbiah.de/news.xml", $group, "Hamster Playground News", 1, "-jh-", true )

HamWebReader( "http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss091.xml", $group, "[News] *" )
HamWebReader( "http://groups-beta.google.com/group/hamster.en.misc/feed/msgs.xml", $group )

# To avoid loading feeds every time, GlobalOnce can be used:
GlobalOnce( "Hourly RSS", 60, HourlyRss )
GlobalOnce( "Daily RSS", 24*60, DailyRss )
GlobalOnce( "Weekly RSS", 7*24*60, WeeklyRss )


sub HourlyRss
   # HamWebReader( ...
end sub

sub DailyRss
   # HamWebReader( ...
end sub

sub WeeklyRss
   # HamWebReader( ...
end sub

HamWebUseProxy( <server>, <port>, <user>, <pass> )

This function can be used to define any required HTTP proxy settings for subsequent calls to HamWebReader or HamWebHtmlLoad.

Proxy server is given by <server> (IP or DNS name) and <port> number.

If proxy server requires authentication, username and password can directly given by <user> and <pass>. To use one of Hamster's script passwords instead, use "$42" as <user> with "42" replaced by appropriate password number.

Returns: Always 0

HamWebUseProxy( "", 8080, "$25" )

HamWebReader( "http://www.elbiah.de/news.xml", $group, "Hamster Playground News", 1, "-jh-", true )

HamWebUseProxy()   # clear proxy settings

HamWebHtmlLoad( <url> )

Loads the HTML text from the given <url>.

Returns: HTML text (empty string on errors).

varset( $html, HamWebHtmlLoad( "http://www.elbiah.de/news.htm" ) )

HamWebHtmlToText( <html-text> )

Converts the given <html-text> into a (more or less) readable plain text.

Returns: HTML text converted to plain text (empty string on errors).

varset( $text, HamWebHtmlToText( $html ) )

[www.elbiah.de Hamster Playground Documentation]