|
Joined: Dec 2002
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Dec 2002
Posts: 111 |
Can anyone help me with this..
alias tib.s {
sockclose Tibia
sockopen Tibia www.tibia.4players.de 80
if ($1-) {
.sockmark Tibia $+(/community/?subtopic=character&name=,$1-)
}
}
on *:sockopen:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on open) \ $sockname - $sock($sockname).ip
return
}
sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Host: www.tibia.com
sockwrite -n $sockname $crlf
}
on *:sockread:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on read) \ $sockname - $sock($sockname).ip
return
}
sockread -fn %tmp
echo -a $iif(%tmp == $null,-,%tmp)
}
It's supposed to connect to.. http://tibia.4players.de/community/?subtopic=character&name=NAME, where NAME is what you use with the alias. I was wanting it to give me everything about the player up to Residence, and no more. Think anyone can help? Thanks. Regards, Dillon Dixon (Magus)
Experience The Void.. Are You Ready?
|
|
|
|
Joined: Dec 2002
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Dec 2002
Posts: 111 |
Well, I've got this far.. it now gets the desired info, and a little more I dont really need.. I'll continue to tweak it a bit, but the html stripping I'm gonna need help with.. anyone?
alias tib.s {
sockclose Tibia
sockopen Tibia www.tibia.4players.de 80
;http://tibia.4players.de/community/?subtopic=character&name=Rott
if ($1-) {
.sockmark Tibia $+(/community/?subtopic=character&name=,$1-)
}
}
on *:sockopen:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on open) \ $sockname - $sock($sockname).ip
return
}
sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Host: www.tibia.4players.de
sockwrite -n $sockname $crlf
}
on *:sockread:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on read) \ $sockname - $sock($sockname).ip
return
}
sockread -fn %tmp
if (This character does not exist isin %tmp) {
echo -s This character doesnt exist
goto end
}
if (<TABLE BORDER isincs %tmp) && (%c == $null) {
echo -s $iif(%tmp == $null,$chr(160),%tmp)
set %c Null
}
:end
unset %tmp %c
halt
}
Experience The Void.. Are You Ready?
|
|
|
|
Joined: Feb 2003
Posts: 8
Nutrimatic drinks dispenser
|
Nutrimatic drinks dispenser
Joined: Feb 2003
Posts: 8 |
I had this problem too, and I got help to it here, so I hope it will help you too...
|
|
|
|
Joined: Dec 2002
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Dec 2002
Posts: 111 |
Ah, it does, very helpful! Thanks
Experience The Void.. Are You Ready?
|
|
|
|
Joined: Dec 2002
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Dec 2002
Posts: 111 |
Ok! well, I have this now:
alias tib.s {
sockclose Tibia
sockopen Tibia www.tibia.4players.de 80
;http://tibia.4players.de/community/?subtopic=character&name=Rott
if ($1-) {
.sockmark Tibia $+(/community/?subtopic=character&name=,$1-)
}
}
on *:sockopen:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on open) \ $sockname - $sock($sockname).ip
return
}
sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Host: www.tibia.4players.de
sockwrite -n $sockname $crlf
}
on *:sockread:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on read) \ $sockname - $sock($sockname).ip
return
}
sockread -fn %tmp
if (doesn't exist. isin %tmp) {
echo -s This character doesnt exist
goto end
}
if (Character Information isin %tmp) {
echo -s $removehtml($gettok($iif(%tmp == $null,-,%tmp),1,58))
echo -s $removehtml($gettok($iif(%tmp == $null,-,%tmp),2,58))
echo -s $removehtml($gettok($iif(%tmp == $null,-,%tmp),3,58))
echo -s $removehtml($gettok($iif(%tmp == $null,-,%tmp),4,58))
echo -s $removehtml($gettok($iif(%tmp == $null,-,%tmp),5,58))
echo -s $removehtml($gettok($iif(%tmp == $null,-,%tmp),6,58))
echo -s $removehtml($gettok($iif(%tmp == $null,-,%tmp),7,58))
}
:end
unset %tmp %c
halt
}
alias removehtml {
var %a
!.echo -q $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,,%a)
return %a
}
And it works perfectly thanks to that alias, but.. this is what I get echo'd: Character informationName RottSex maleProfession KnightLevel 17World LiberaResidence CarlinLast login Blah, I need to have that seperated somehow.. anyone know how I could edit that alias (if it's ok that I edit it for this) so that it only gives me the first word in the string of html, insted of all words? Thanks
Experience The Void.. Are You Ready?
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
Add all the characters to a single string variable. You know what the format will be and you can use $regsub() and /tokenize to parse it out into variables very easily!
alias tib.s {
sockclose Tibia
sockopen Tibia www.tibia.4players.de 80
; http://tibia.4players.de/community/?subtopic=character&name=Rott
if ($1-) {
.sockmark Tibia $+(/community/?subtopic=character&name=,$1-)
}
}
on *:sockopen:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on open) \ $sockname - $sock($sockname).ip
return
}
sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
sockwrite -n $sockname Host: www.tibia.4players.de
sockwrite -n $sockname Accept: */*
sockwrite $sockname $crlf
}
on *:sockread:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on read) \ $sockname - $sock($sockname).ip
return
}
var %tmp
sockread -fn %tmp
if (doesn't exist. isin %tmp) $&
echo -s This character doesnt exist
elseif (Character Information isin %tmp) {
tokenize 32 $CharData($RemoveHTML(%tmp))
var -s %Name = $1 | ; Save the name
var -s %Sex = $2 | ; Save the gender
var -s %Profession = $3 | ; Save the profession
var -s %Level = $4 | ; Save the level
var -s %World = $5 | ; Save the world
var -s %Residence = $6 | ; Save the residence
;
; Presumably, you'd want to pass the values to another alias or write them somewhere.
; You'd do that here.
;
}
}
alias RemoveHTML {
var %a
!.echo -q $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,,%a)
return %a
}
alias CharData {
var %a
!.echo -q $regsub($1-, /(^Character informationName:|Sex:|Profession:|Level:|World:|Residence:|Last login$)/g, $chr(32), %a)
return %a
}
And then you're home free. Incidentally, I didn't see a %c to unset; if you /var %tmp, you won't have to unset it.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Dec 2002
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Dec 2002
Posts: 111 |
Erm.. after sorting all that out in the editor, it didnt work, but I'd got it to work anyway.. before I came back and read this.
alias tib.s {
sockclose Tibia
sockopen Tibia www.tibia.4players.de 80
if ($1-) {
.sockmark Tibia $+(/community/?subtopic=character&name=,$replace($1-,$chr(32),$eval(%20,0)))
set %c $1-
}
}
on *:sockopen:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on open) \ $sockname - $sock($sockname).ip
return
}
sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Host: www.tibia.4players.de
sockwrite -n $sockname $crlf
}
on *:sockread:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on read) \ $sockname - $sock($sockname).ip
return
}
var %tmp
sockread -fn %tmp
if (doesn't exist. isin %tmp) {
echo -s This character doesnt exist
halt
}
if (Character Information isin %tmp) {
echo -a Character Information:
echo -s Name: $left($removehtml($gettok($iif(%tmp == $null,-,%tmp),2,58)),$len(%c))
echo -s Sex: $uperl($iif(female isin $removehtml($gettok($iif(%tmp == $null,-,%tmp),3,58)), $&
$left($removehtml($gettok($iif(%tmp == $null,-,%tmp),3,58)),6),$left($removehtml($gettok( $&
$iif(%tmp == $null,-,%tmp),3,58)),4)))
echo -s Profession: $remove($removehtml($gettok($iif(%tmp == $null,-,%tmp),4,58)),level)
echo -s Level: $remove($removehtml($gettok($iif(%tmp == $null,-,%tmp),5,58)),world)
echo -s World: $remove($removehtml($gettok($iif(%tmp == $null,-,%tmp),6,58)),residence)
echo -s Residence: $remove($removehtml($gettok($iif(%tmp == $null,-,%tmp),7,58)),last login)
echo -s -
}
halt
}
alias removehtml {
var %a
!.echo -q $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,,%a)
return %a
}
alias -l uperl return $+($upper($left($1-,1)),$right($1-,-1))
Thanks though
Last edited by Hammer; 26/02/03 04:23 PM.
Experience The Void.. Are You Ready?
|
|
|
|
Joined: Dec 2002
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Dec 2002
Posts: 111 |
Er.. ok, new errors.
1. If someone's in a guild, it errors 2. If someone ahs had a former name it errors.
Try that on Tanker and Light Foot
Notice how it's errored for tanker, and for light foot the last line is errored.. I'm a bit too confused to fix it, so could someone help?
Experience The Void.. Are You Ready?
|
|
|
|
|