mIRC Homepage
Posted By: Dominicz Information from Websites - 18/06/04 06:28 PM
I'm stuck at the moment.. I've started 'Scripting' and I'm not too good.. I have a question..

Would there be a way for me to make a script that when people say something like "!news" It would go to a website and find the news...

For Example if I wanted it to go to Runescape.com and get the title of the first News Headline and then type it out in the chatroom... any ideas?
Posted By: Sigh Re: Information from Websites - 18/06/04 07:00 PM
This can be accomplished through use of sockets on mIRC, you basically need to open a socket to the web server and request the information through HTTP specific commands. You may find it useful to read this tutorial on data retrieval using sockets as it contains information relevant to finding the solution to your problem:

http://www.mircscripts.org/showdoc.php?type=tutorial&id=1217
Posted By: Dominicz Re: Information from Websites - 18/06/04 07:01 PM
Ok, Thanks!
Posted By: Dana Re: Information from Websites - 18/06/04 07:05 PM
Yes, it's quite possible but you'd need to learn how to use sockets.

Jagfire's tutorial should be able to help you.
Posted By: Dominicz Re: Information from Websites - 19/06/04 06:42 AM
I've looked over the tutorials and tried to make one.. I've come up with this but when I type /playing nothing happens..

alias Playing sockopen Playing www.runescape.com 80

on *:sockopen:Playing:{
sockwrite -n $sockname GET / HTTP/1.1
sockwrite -n $sockname Host: www.runescape.com $+ $crlf $+ $crlf

}

on *:sockread:Playing:{
if ($sockerr) {
echo -a Error.
halt
}
else {

var %temptext

sockread %temptext
if (<span style="font-size:14px; color:white;">There are currently * people playing! isin %temptext) { set %EK $htmlfree(%temptext) }
{ /msg #blehtesting %EK }
}
}
}

any thoughts?
Posted By: Gods_Hell Re: Information from Websites - 23/06/04 11:26 AM
Code:
on *:sockopen:Playing:{ 
  sockwrite -nt $sockname GET $+(/aff/runescape/title.html) HTTP/1.1 
  sockwrite -nt $sockname Accept-Language: en-us
  sockwrite -nt $sockname User-Agent: Mozilla/??
  sockwrite -nt $sockname Host: www.runescape.com
  sockwrite -nt $sockname Proxy-Connection: Keep-Alive
  sockwrite -nt $sockname Connection: Keep-Alive
  sockwrite -t $sockname $str($crlf,2)
} 
on *:sockread:Playing:{ 
  if ($sockerr &gt; 0) { return | /sockclose Playing }
  sockread -f %temptext 
  var %freehtml $htmlfree(%temptext)
  if (*There?are?currently*people?playing!* iswm %freehtml) { /msg #blehtesting %freehtml } 
} 
alias -l htmlfree {
  var %x, %i = $regsub($1-,/(^[^&lt;]*&gt;|&lt;[^&gt;]*&gt;|&lt;[^&gt;]*$)/g,$null,%x), %x = $remove(%x,&amp;nbsp;)
  return %x
}
on *:text:!players:#blehtesting:{
  sockclose Playing
  sockopen Playing www.runescape.com 80
}


should work!
© mIRC Discussion Forums