mIRC Home    About    Download    Register    News    Help

Print Thread
#134794 05/11/05 12:48 AM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
Is there a script for a CNN headline grabber anywhere. I've searched many of the irc sites and have had little luck. I just need something that grabs the headline from cnn.com (or any other major news site for that matter) and sends it to a channel(s) every hour or so. I found something called NetNews Series v1.4 but it doesn't display the news to a channel every hour, rather, it just opens up a custom window and displays the information there. Or, is there a way to configure the script to get it to message the headlines to a channel? Thank you.

Last edited by gliX; 05/11/05 12:49 AM.
#134795 07/11/05 01:11 AM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
I guess no one knows?

#134796 07/11/05 02:50 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Search that script for aline. The line should look something like:

aline @News $1-
or
aline @News %news_variable

You should change it to something like:

msg #yourchannel $1-
or
msg #yourchannel %news_variable

See if that helps you. Without seeing the script, I can just give suggestions. It will still open the @News window unless you remove the window command in the script.

Just as a note, it could flood you off if you have many lines to display.

Beyond that, look up /help sockets for more information on making your own.


Invision Support
#Invision on irc.irchighway.net
#134797 07/11/05 03:14 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
Hmm i don't see aline, here's a FOX News script. It gets the headlines in a separate window, and lets you send them to other channels but you have to do it manually. Is there a way to change it so it does 2-3 headlines automatically by the hour

Quote:
; [nI] FOXNews Headlines v2.1
;
; Usage: /getnews
; Installation: /load -rs ni-FOXNews.mrc
;

on *:LOAD:{
echo $color(info) -s [nI] FOXNews Headlines v2.1 Loaded...
echo $color(info) -s * Usage: /getnews
echo $color(info) -s -
}
alias getnews {
if $sock(FOX) != $null { sockclose FOX }
sockopen FOX www.FOXNews.com 80
.unset %FOX.line
.unset %FOX.temp
.set %FOXNews.output $+(",$scriptdir,FOX-news.txt,")
.set %FOXNews.output2 $+(",$scriptdir,FOX-urls.txt,")
write -c %FOXNews.output
write -c %FOXNews.output2
if $dialog(FOX) != $null { dialog -v FOX }
else { dialog -mv FOX FOX }
did -r FOX 5
did -ra FOX 27 http://www.FOXNews.com
}
alias saveheadlines {
set %fox.savefile $sfile($scriptdir $+ *.txt,Save Headlines As...,Save)
if %fox.savefile == $null {
halt
}
else {
write -c %fox.savefile
write %fox.savefile [nI] FOXNews Headlines -- ZeroSyrge
write %fox.savefile $str(-,35)
write %fox.savefile Date: $chr(9) %fox.updatetime
write %fox.savefile $str($crlf,2)
write %fox.savefile [url= $str($chr(9),7) [HEADLINE]
.unset %fox.save1
.set %fox.save2 $lines(%FOXNews.output)
:next
inc %fox.save1
if %fox.save1 <= %fox.save2 {
write %fox.savefile $read(%FOXNews.output2,%fox.save1) $chr(9) $read(%FOXNews.output,%fox.save1)
goto next
}
else {
echo $color(info) -se * Saved Headlines To: %fox.savefile
run notepad %fox.savefile
}
}
}
on *:sockopen:FOX:{
sockwrite -n $sockname GET /index.html HTTP/1.0
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Accept-Language: en-us
sockwrite -n $sockname Accept-Encoding: gzip, deflate
sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
sockwrite -n $sockname Host: [url=http://www.FOXNews.com]www.FOXNews.com] $str($chr(9),7) [HEADLINE]
.unset %fox.save1
.set %fox.save2 $lines(%FOXNews.output)
:next
inc %fox.save1
if %fox.save1 <= %fox.save2 {
write %fox.savefile $read(%FOXNews.output2,%fox.save1) $chr(9) $read(%FOXNews.output,%fox.save1)
goto next
}
else {
echo $color(info) -se * Saved Headlines To: %fox.savefile
run notepad %fox.savefile
}
}
}
on *:sockopen:FOX:{
sockwrite -n $sockname GET /index.html HTTP/1.0
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Accept-Language: en-us
sockwrite -n $sockname Accept-Encoding: gzip, deflate
sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
sockwrite -n $sockname Host: [url=http://www.FOXNews.com]www.FOXNews.com[/url]
; sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname
did -a FOX 5 Connecting, please wait...
}
on *:sockread:FOX:{
.unset %FOX.x*
set %FOX.a <a href="/story/0,
if ($sockerr > 0) return
:next
.inc %FOX.line
sockread %FOX.temp
if ($sockbr == 0) return
if (%FOX.temp == $null) %FOX.temp = -
if %FOX.a isin %FOX.temp {
if ($striphtml(%FOX.temp) == $null) || ($gettok($gettok($replace(%FOX.temp,<a,$chr(173)),2,173),2,34) == $null) { goto next }
write %FOXNews.output2 http://www.FOXNews.com $+ $gettok($gettok($replace(%FOX.temp,<a,$chr(173)),2,173),2,34)
if &#149; isin $gettok($striphtml(%FOX.temp),1,32) { set %FOX.temp $gettok($striphtml(%FOX.temp),2-,32) }
if &#149; isin $striphtml(%FOX.temp) { set %FOX.temp $replace($striphtml(%FOX.temp),&#149;,--[FOX]--) }
write %FOXNews.output $striphtml(%FOX.temp)
}
goto next
}
on *:sockclose:FOX:{
did -r FOX 5
did -a FOX 7 Double-Clicking a Headline Will Open It In Your Browser... (Updated: $asctime(mmmm doo $+ $chr(44) yyyy -- hh:nntt) $+ )
set %fox.updatetime $asctime(mmmm doo $+ $chr(44) yyyy -- hh:nntt)
FOXdialog
}
; $striphtml by fubar
alias striphtml {
if ($1) {
var %strip,%parm = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
while ($gettok($gettok(%parm,%n,62),1,60)) {
%strip = %strip $ifmatch
inc %n
}
return %strip
}
}
alias FOXdialog {
if $dialog(FOX) != $null { dialog -v FOX }
else { dialog -mv FOX FOX }
.unset %fox.b1
.set %fox.b2 $lines(%FOXNews.output)
:next
inc %fox.b1
if %fox.b1 <= %fox.b2 {
did -a FOX 5 $read(%FOXNews.output,%fox.b1)
goto next
}
else { return }
}
dialog FOX {
title "[nI] FOXNews Headlines v2.1"
icon $scriptdir $+ FOXNews.ico
size -1 -1 350 170
option -dbu
text "Double-Clicking a Headline Will Open It In Your Browser...", 7, 10 145 325 6
box "FOXNews Headlines", 1, 5 1 340 152
list 5, 10 11 330 145, edit, autovs, extsel, autohs
button "CLOSE", 15, 310 156 30 11, cancel
button "Update", 17, 10 156 30 11, default
button "Copy HL", 19, 250 156 30 11, tab1
button "Copy URL", 21, 280 156 30 11, tab2
button "Send MSG", 23, 220 156 30 11, tab3
button "Go!", 25, 190 156 30 11, tab4
edit "http://www.FOXNews.com", 27, 41 156 148 11
menu "&File", 50
item "&Update", 60
item break, 70
item "&Save As...", 80
item break, 90, 50
item "&Close", 100, ok
menu "&Help", 110
menu "&Contact", 120, 110
item "&Visit Website", 130
item break, 140
item "&Send E-Mail", 150
item break, 160, 110
item "&About", 170
}
on *:DIALOG:FOX:sclick:*: {
if ($did == 5) {
did -t FOX 25
did -ra FOX 27 $read(%FOXNews.output2,$did(5).sel)
}
if ($did == 17) { getnews }
if ($did == 19) { clipboard $did(5).seltext }
if ($did == 21) { clipboard $read(%FOXNews.output2,$did(5).sel) }
if ($did == 23) && ($did(5).sel != $null) {
set %FOX.msgnick $?="Send this Headline to... "
if (%FOX.msgnick != $null) {
msg %FOX.msgnick [Headline] $did(5).seltext
msg %FOX.msgnick [url= $read(%FOXNews.output2,$did(5).sel)
}
}
if ($did == 25) && ($did(5).sel != $null) { url -n $read(%FOXNews.output2,$did(5).sel) }
else { halt }
}
on *:DIALOG:FOX:dclick:*: {
if ($did == 5) { url -n $read(%FOXNews.output2,$did(5).sel) }
else { halt }
}
on *:DIALOG:FOX:close:*: {
if $sock(FOX) != $null { sockclose FOX }
}
on *:DIALOG:FOX:menu:*: {
if ($did == 60) { getnews }
if ($did == 80) { saveheadlines }
if ($did == 130) { url -n [url=http://www.horiz0n.com/ni/]http://www.horiz0n.com/ni/] $read(%FOXNews.output2,$did(5).sel)
}
}
if ($did == 25) && ($did(5).sel != $null) { url -n $read(%FOXNews.output2,$did(5).sel) }
else { halt }
}
on *:DIALOG:FOX:dclick:*: {
if ($did == 5) { url -n $read(%FOXNews.output2,$did(5).sel) }
else { halt }
}
on *:DIALOG:FOX:close:*: {
if $sock(FOX) != $null { sockclose FOX }
}
on *:DIALOG:FOX:menu:*: {
if ($did == 60) { getnews }
if ($did == 80) { saveheadlines }
if ($did == 130) { url -n [url=http://www.horiz0n.com/ni/]http://www.horiz0n.com/ni/[/url] }
if ($did == 150) { url -n ZeroSyrge@horiz0n.com }
if ($did == 170) { foxaboutdialog }
}
alias FOXaboutdialog {
if $dialog(FOXabout) != $null { dialog -v FOXabout }
else { dialog -mvo FOXabout FOXabout }
}
dialog FOXabout {
title "[nI] FOXNews Headlines -- About"
icon $scriptdir $+ FOXNews.ico
size -1 -1 106 45
option -dbu
box "FOXNews Headlines", 1, 3 1 100 41
text "Version: 2.1", 3, 6 8 100 8
text "Author: ZeroSyrge", 5, 6 16 100 8
text "E-Mail:", 7, 6 24 25 8
text "URL:", 9, 6 32 25 8
link "ZeroSyrge@horiz0n.com", 11, 32 24 70 8
link "http://www.horiz0n.com/ni/", 13, 32 32 70 8
button "Close", 15, 71 5 30 11, cancel
}
on *:DIALOG:FOXabout:sclick:*:{
if ($did == 11) { url -n ZeroSyrge@horiz0n.com }
if ($did == 13) { url -n http://www.horiz0n.com/ni/ }
}
menu menubar,status,channel, {
-
[FOXNews]:/getnews
}

Last edited by gliX; 07/11/05 03:15 PM.
#134798 07/11/05 03:28 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well...
.set %FOXNews.output $+(",$scriptdir,FOX-news.txt,")
.set %FOXNews.output2 $+(",$scriptdir,FOX-urls.txt,")

So, all the news is stored there. It's not in a custom window. Perhaps you were talking about the dialog instead.

At the end of the sockclose section, you can just add a /play command...

Code:
on *:sockclose:FOX:{ 
  did -r FOX 5 
  did -a FOX 7 Double-Clicking a Headline Will Open It In Your Browser... (Updated: $asctime(mmmm doo $+ $chr(44) yyyy -- hh:nntt) $+ ) 
  set %fox.updatetime $asctime(mmmm doo $+ $chr(44) yyyy -- hh:nntt) 
  FOXdialog 
  play [color:red]#yourchannel[/color] %FOXNews.output
} 


Note that if you want the urls, you can use %FOXNews.output2 instead.

To get it to run automatically, you can use a timer...

/timer 0 3600 getnews

As for making it display only a few parts of the news, that would require more editing than I'm really willing to do.


Invision Support
#Invision on irc.irchighway.net
#134799 07/11/05 03:52 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
Thanks. Is there a simple code I can enter in so it only displays the first two headlines? Usually the first two headlines are of most importance.

#134800 07/11/05 04:00 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You could do something like this:
Code:
  write %FOXNews.output2 http://www.FOXNews.com $+ $gettok($gettok($replace(%FOX.temp,&lt;a,$chr(173)),2,173),2,34) 
  if &amp;#149; isin $gettok($striphtml(%FOX.temp),1,32) { set %FOX.temp $gettok($striphtml(%FOX.temp),2-,32) } 
  if &amp;#149; isin $striphtml(%FOX.temp) { set %FOX.temp $replace($striphtml(%FOX.temp),&amp;#149;,--[FOX]--) } 
  write %FOXNews.output $striphtml(%FOX.temp) 
  [color:red]inc %fox.cnt
  if (%fox.cnt == 2) { sockclose FOX | unset %fox.cnt }[/color]


The red is what I added to what is already there. It should work for you.


Invision Support
#Invision on irc.irchighway.net
#134801 07/11/05 04:36 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
It says * /sockread: socket unavailable (line 69, ni-foxnews.mrc)

line 69 is: sockread %FOX.temp

#134802 07/11/05 04:41 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ah, I see... for some reason, they're using GOTO. Just change this:

if (%fox.cnt == 2) { sockclose FOX | unset %fox.cnt }

to this:

if (%fox.cnt == 2) { sockclose FOX | unset %fox.cnt | return }


Invision Support
#Invision on irc.irchighway.net
#134803 07/11/05 05:58 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
As for your original request, you can try this code:

/*

Usage:

/cnnrss <number> [optional command], returns the title of the headline, followed by the url

If you don't specify a command, it will echo the headlines to the active window.

Examples:

/cnnrss 3
/cnnrss 5 msg #mychannel
/cnnrss 10 aline @cnn

Requirements: mIRC 6.16, should work on any version of Windows.

*/

Code:
alias cnnrss {
  if ($1 !isnum 1-) {
    echo -ac info * /cnnrss: must specify number of recent headlines
    return
  }
  var %t = $ticks, %rss = rss $+ %t, %nodecol = nodecol $+ %t, %item = item $+ %t
  var %children = children $+ %t, %cmd = $iif($2,$2-,echo -a), %tmp
  .comopen %rss Msxml2.DOMDocument
  if ($comerr) return COM Error
  %tmp = $com(%rss,async,4,bool,false)
  %tmp = $com(%rss,load,1,bstr*,http://rss.cnn.com/rss/cnn_latest.rss)
  .comclose %rss $com(%rss,selectnodes,1,bstr*,/rss/channel/item,dispatch* %nodecol)
  var %i = 1, %ii = $comval(%nodecol,0)
  while (%i &lt;= $1) &amp;&amp; (%i &lt;= %ii) {
    %tmp = $com(%nodecol,item,1,uint,%i,dispatch* %item) 
    if ($com(%item)) {
      .comclose %item $com(%item,childnodes,3,dispatch* %children) 
      if ($com(%children)) {
        %cmd %i - $comval(%children,1,text) ** $deltok($comval(%children,2,text),-1,63)
        .comclose %children
      }
    }
    inc %i
  }
  .comclose %nodecol
}


Gone.
#134804 07/11/05 07:05 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Hm... that's interesting. I haven't looked into using RSS (in mIRC or otherwise). It looks like it could make reading data off sites that have RSS feeds much easier. smile


Invision Support
#Invision on irc.irchighway.net
#134805 07/11/05 08:04 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
wow fiberoptics you rock, works perfectly. i used

on *:TEXT:.cnn*:#: { if ($2 != $null) { cnnrss $2 notice $nick | halt } | cnnrss 1 notice $nick }

That way, the command .cnn triggers 1 headline via notice, .cnn 2 triggers 2, etc..

Only one problem, is there a way to have relevant headlines displayed or is it random? When I used it, it didn't display headlines from the main page, it displayed these headlines instead:

[15:02] -FairServ- 1 - Eto'o in line to keep Africa honor ** http://www.cnn.com/rssclick/2005/SPORT/football/11/07/africa.awards/index.html
[15:02] -FairServ- 2 - France PM: Curfews to stem riots ** http://www.cnn.com/rssclick/2005/WORLD/europe/11/07/france.riots/index.html
[15:02] -FairServ- 3 - Monday, November 7 ** http://www.cnn.com/rssclick/2005/US/11/07/monday/index.html
[15:02] -FairServ- 4 - What's up with that snowman T-shirt? ** http://www.cnn.com/rssclick/2005/SHOWBIZ/Music/11/07/snowman.tshirt.ap/index.html

but thanks for the help thats exactly what i was looking for, and thank you riamus too. cool

#134806 08/11/05 01:51 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
@Riamus: An RSS is simply an XML file, which can be parsed easily with COM.

@gliX:

/*

Usage: /cnnrss <number of headlines>, <category> [,command]

If no command is specified, it will echo the results to the active window.

Categories:

Africa
Americas
Asia
Entertainment
Europe
Football
Middle East
Most Recent
Science and Space
Sport
Technology
Top Stories
Travel
US
World
World Business

Examples:

/cnnrss 3, Top Stories
/cnnrss 5, Most Recent, msg #channel
/cnnrss 8, Sport, aline @cnn

Requirements: mIRC 6.16

*/

Code:
alias cnnrss {
  var %e = echo -ac info * /cnnrss:, %tmp, %cat, %url
  if ($isid) { %e can only be used as a command. | return }
  tokenize 44 $(,,$regsub($1-,/\s*(?=\54)|(?&lt;=\54)\s*/g,,%tmp)) %tmp
  if ($1 !isnum 1-) { %e must specify number of recent headlines. | return }
  var %categories = Top Stories,World,Africa,Americas,Asia,Europe,Middle East,Us, $+ $&amp;
    World Business,Technology,Science and Space,Entertainment,Sport,Football,Travel,Most Recent
  if (!$istok(%categories,$2,44)) {
    tokenize 44 $sorttok(%categories,44)
    %e incorrect category specified - Possible categories:
    echo -a $*
    return
  }
  if ($2 == middle east) %cat = _meast.rss
  elseif ($2 == science and space) %cat = _space.rss
  elseif ($2 == world business) %cat = _business.rss
  elseif ($2 == top stories) %cat = .rss
  else %cat = _ $+ $2.rss
  %url = http://rss.cnn.com/rss/ $+ $iif($2 == most recent,cnn_latest.rss,edition $+ %cat)
  var %t = $ticks, %rss = rss $+ %t, %nodecol = nodecol $+ %t, %item = item $+ %t
  var %children = children $+ %t, %cmd = $iif($3,$3,echo -a)
  .comopen %rss Msxml2.DOMDocument
  if ($comerr) { %e COM Error | return }
  %tmp = $com(%rss,async,4,bool,false)
  %tmp = $com(%rss,load,1,bstr*,%url)
  .comclose %rss $com(%rss,selectnodes,1,bstr*,/rss/channel/item,dispatch* %nodecol)
  var %i = 0, %ii = $comval(%nodecol,0)
  while (%i &lt; $1) &amp;&amp; (%i &lt;= %ii) {
    %tmp = $com(%nodecol,item,1,uint,%i,dispatch* %item) 
    inc %i
    if ($com(%item)) {
      .comclose %item $com(%item,childnodes,3,dispatch* %children) 
      if ($com(%children)) {
        %cmd %i - $comval(%children,1,text) ** $deltok($comval(%children,2,text),-1,63)
        .comclose %children
      }
    }
  }
  .comclose %nodecol
}


Gone.
#134807 08/11/05 01:55 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Woops I replied to the wrong person the first time, my bad grin

Wether it is easier or not depends on one important factor: knowledge of COM.

If you don't know COM, then it will be easier to use sockets, however if you know COM there are suddenly a lot of extra possibilities laugh


Gone.
#134808 08/11/05 02:21 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Do you happen to have any site or anything that is good to find all the objects for use with $com?

And, yes... I did know what RSS was... I just never really looked into using it for anything. smile


Invision Support
#Invision on irc.irchighway.net
#134809 08/11/05 02:24 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
There are thousands of COM objects, each with different methods and properties. There is no single list to be linked to.

A great starting point to learn COM, and some objects, is to read this COM tutorial by Shredplayer. After that, it's just a matter of finding the right objects, and issuing the right methods on it, or retrieving the right properties from it. Oh yea, the way "dispatch" works might be very confusing the first time you see it, don't get discouraged though!

Some good COM starting points:

Wscript.Shell
FileSystemObject (FSO)
WMP
WMI

All the snippets I've submitted to ms.org involve COM, so it could be a good starting point to see how objects can be used.


Gone.
#134810 08/11/05 02:39 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Great, thanks. smile


Invision Support
#Invision on irc.irchighway.net
#134811 08/11/05 04:46 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
perfect thanks.

#134812 28/11/05 12:47 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I have released a snippet that will read from basically any RSS News feed you enter, named:

Universal RSS Headline Retriever


Gone.

Link Copied to Clipboard