mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2006
Posts: 10
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Jan 2006
Posts: 10
I need a script that will get The average overall level from the bottom of this page
http://www.runehead.com/clans/ml.php?clan=Theothers
and i want it to be an on text !clanavg and it to say the number from that site


could anyone help? I have no clue how to do it, but it seems hard and help would be appriciated.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Dont forget to set your channel in the top line!
Code:
alias clanavg.channel return #yourchannel
;
#clanavg on
on *:TEXT:!clanavg:$($clanavg.channel):{ clanavg | .disable #clanavg | .timer -o 1 30 .enable #clanavg }
#clanavg end
;
alias -l clanavg {
  echo -at starting
  sockclose clanavg
  sockopen clanavg www.runehead.com 80
}
on *:sockopen:clanavg:{
  sockwrite -n $sockname GET /clans/ml.php?clan=Theothers HTTP/1.0
  sockwrite -n $sockname Host: www.runehead.com
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname $crlf
}
on *:sockread:clanavg:{
  var %text | sockread %text
  if (!$sock(clanavg).mark)        { if (<b>Avg Overall</b> isin %text) { sockmark clanavg 8 } }
  elseif ($sock(clanavg).mark > 1) { sockmark clanavg $calc($sock(clanavg).mark - 1) }
  else                             { msg $clanavg.channel Avg Overall is $gettok($gettok(%text,3,$asc(>)),1,$asc(<)) | sockclose clanavg }
}

* code was tested an ran fine *

The code is dependent on the website NOT changing much,
ie: it looks for the line with <b>Avg Overall</b> on it, then just reads 8 lines down and assumes thats the value and gets it out of <td style='width: 125px;'><b>1,604</b></td> being 1,604 in this case.

Also inacted a 30 second delay before the next !clanavg can be done, sicne it takes time for it to get the value.


Link Copied to Clipboard