Well, after I saw
Sprinkles' idea about web services, I started coding.
The idea of this plugin is to easily share information from the net with your contacts. For example, by typing "/xparse quote einstein" some quotes of einstein will be sended automatically.
Inspired by TB's talkers I decided to make it a very flexible plugin. People can make scripts to handle different websites. The plugin creates a Microsoft XML Domdocument object from a given url, and then the script can filter out the necessary information. Instead of talkers, I call these scripts 'parsers'. At the moment I created 4 different parsers:
- News parser, grabs the latest news headers from cnn
- Quote parser, grabs the Quotes of the Day from quotationspage.com, or searches for quotes when an argument is supplied
- Family guy quote parser, send random quotes from 'The family guy' to your contacts
- Msgweb news parser, quite useless maybe, but it gets the latest news from my website
- Azlyrics.com parser, search for lyrics
- dictionary.com, get the meaning of a word...
- Parser for http://www.timeanddate.com/worldclock/ to get the current time in all big cities
For now I didn't make a dll yet, so I can't upload a plugin version, but here is a screenshot of the config window. It clearly illustrates the use of the plugin:
I'd like to know
- what you think of this idea.
- what features you'd like to see in the final version.
- what parsers you think would be useful.
- who's interested in developing parsers
- what would be a good name for the plugin ;)
For the scripters, here is the source of the quote parser (quote.vbs)
code:
sub info() 'purpose: give the config screen all the parser info
engine.description = "Share more than 20,000 famous quotes with your contacts"
engine.help = "This parser gets the quotes from http://www.quotationspage.com. When you don't supply a parameter the parser will show you the quotes of the day. Otherwise it'll do a search for the supplied text."
engine.syntax = "<search (optional)>"
end sub
sub run()
if trim(engine.argument) <> "" then
url = "http://www.quotationspage.com/search.php3?homesearch=" & trim(engine.argument)
else
url = "http://www.quotationspage.com/qotd.html"
end if
engine.getXML cstr(url), "parse", true
end sub
'There is a regularity in the source code of the website:
'all quotes are between <dt> tags
'all authors are between <dd> tags, and are shown bold (with a <b> tag)
'with this information we can make the follow code:
'note that the xml object is data.xml
sub parse(xml) 'purpose: filter the xmlobject
i = 0
for each item in xml.getElementsByTagName("dt")
if str = "" then
str = item.Text & vbcrlf & "---" & xml.getElementsByTagName("dd").item(i).getElementsByTagName("b").item(0).text
else
str = str & vbcrlf & vbcrlf & item.Text & vbcrlf & "---" & xml.getElementsByTagName("dd").item(i).getElementsByTagName("b").item(0).text
end if
i = i + 1
next
engine.output cstr(str)
end sub
As you can see it ain't that much code to handle a single website...
Let me hear what you think
edit: Installer link:
http://shoutbox.menthix.net/attachment.php?pid=379120
API Tutorial link:
http://www.msgweb.nl/en/MEWS/tutorial.php