mIRC Home    About    Download    Register    News    Help

Print Thread
#215846 10/10/09 02:19 PM
Joined: Oct 2009
Posts: 1
B
beni87 Offline OP
Mostly harmless
OP Offline
Mostly harmless
B
Joined: Oct 2009
Posts: 1
I have a small problem, i got my socket script that reads from rss and then post the latest news, but it seems it only works on a few sites. Here's code:

Code:
alias bbc-rss {
  if ($sock(bbc-rss)) { sockclose bbc-rss }
  sockopen bbc-rss newsrss.bbc.co.uk 80
}
on *:sockopen:bbc-rss: {
  sockwrite -n $sockname GET /rss/newsonline_world_edition/front_page/rss.xml HTTP/1.1
  sockwrite -n $sockname Host: newsrss.bbc.co.uk $+ $crlf $+ $crlf
}
on *:sockread:bbc-rss: {
  if ($sockerr) { halt }
  else {
    var %s.data
    sockread %s.data
    if (<item> isin %s.data) { set %s.item 1 }
    if (<title> isin %s.data) || (<link> isin %s.data) && (%s.item) {
      set %d. [ $+ [ $remove($gettok(%s.data,-1,60),$chr(47),$chr(62)) ] ] $remove(%s.data,<title>,</title>,<link>,</link>)
    }
    if (%d.title) && (%d.link) {
      echo -a News: %d.title ยป  $+ $remove(%d.link,$chr(32)) $+
      unset %s.* %d.*
      sockclose $sockname
    }
  }
}



So far i know all rss feeds have <item>, <title> and <link> in it, so i dont see why it wont work on all sites. Anyone know what i can do to make it work on all rss feeds?

beni87 #215848 10/10/09 06:12 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Not all feeds are RSS2.0

Some are Atom, which is a different format.

Of course there's also the issue that you're assuming that

1. the text of interest is on the same line as the <link>/<title> tags
2. <title> isn't on the same line as <link>
3. the first < of the line is from the <title> or <link> tag

and I'm sure there are other logic errors in that script. None of those 3 points are guaranteed.

You should try to find a proper XML parsing dll/script for an RSS feed.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
beni87 #215850 10/10/09 08:20 PM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Or just echo the page to a window and figure out how to parse the info you need.

DJ_Sol #215851 10/10/09 08:30 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
He wants it to work on "all" (or most, I guess) feeds.. this can't be done by example... it can only be done by properly parsing XML, which mIRC isn't too great at.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #215852 10/10/09 11:47 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Shameless plug but you could use my [url=XML Parser]http://www.mirc.net/projects.php?view_snippet=1236016348[/url]. It also includes an example alias that parses an online rss feed.


$maybe

Link Copied to Clipboard