| View previous topic :: View next topic |
| Author |
Message |
]x[ Voice
Joined: 09 Jan 2006 Posts: 14
|
Posted: Sat Dec 01, 2007 9:43 pm Post subject: What Pulse script |
|
|
Trying to get this old Whatpulse script working again with the new web API but i can't seem to be able to fix it. The problem is that the old API was a txt output and the new one is an XML. This is the site where it needs to get the data from :
http://whatpulse.org/api/user.php?UserID=223348
This is the original version of the script -> http://pastebin.com/f35b6b778
Then i fiddled a bit with info from this forum and tutorials. I got it to to read the xml file and output something. But i can't seem to refine the output.
Working script till now -> http://pastebin.com/m34521008
Which outputs this -> http://pastebin.com/m53c44d46
But i can't figure out how i can get the output ^^ in to a nice format so i can deliver it to IRC how i want.
And below here is my try in getting something but that only messed up me script and makes it output errors in DCC instead of some nice output..
| Code: |
package require http
bind pub - !test pulse_get
proc pulse_get {n u h c t} {
set x [::http::geturl http://whatpulse.org/api/user.php?UserID=223348]
foreach line [split [::http::data $x] \n] {
regsub -line {<AccountName>} set $AccountName {} AccountName
regsub -line {<Country>} set $Country {} Country
regsub -line {<DateJoined>} set $DateJoined {} DateJoined
regsub -line {<Homepage>} set $Homepage {} Homepage
regsub -line {<LastPulse>} set $LastPulse {} LastPulse
regsub -line {<Pulses>} set $Pulses {} Pulses
regsub -line {<TotalKeyCount>} set $TotalKeyCount {} TotalKeyCount
regsub -line {<TotalMouseClicks>} set $TotalMouseClicks {} TotalMouseClicks
regsub -line {<AvKeysPerPulse>} set $AvKeysPerPulse {} AvKeysPerPulse
regsub -line {<AvClicksPerPulse>} set $AvClicksPerPulse {} AvClicksPerPulse
regsub -line {<AvKPS>} set $AvKPS {} AvKPS
regsub -line {<AvCPS>} set $AvCPS {} AvCPS
regsub -line {<Rank>} set $Rank {} Rank
regsub -line {<TeamID>} set $TeamID {} TeamID
regsub -line {<TeamName>} set $TeamName {} TeamName
regsub -line {<TeamMembers>} set $TeamMembers {} TeamMembers
regsub -line {<TeamKeys>} set $TeamKeys {} TeamKeys
regsub -line {<TeamClicks>} set $TeamClicks {} TeamClicks
regsub -line {<TeamDescription>} set $TeamDescription {} TeamDescription
regsub -line {<TeamDateFormed>} set $TeamDateFormed {} TeamDateFormed
puthelp "privmsg $c :AccountName"
puthelp "privmsg $c :Country"
puthelp "privmsg $c :DateJoined"
puthelp "privmsg $c :Homepage"
puthelp "privmsg $c :LastPulse"
puthelp "privmsg $c :Pulses"
puthelp "privmsg $c :TotalKeyCount"
puthelp "privmsg $c :TotalMouseClicks"
puthelp "privmsg $c :AvKeysPerPulse"
puthelp "privmsg $c :AvClicksPerPulse"
puthelp "privmsg $c :AvKPS"
puthelp "privmsg $c :AvCPS"
puthelp "privmsg $c :Rank"
puthelp "privmsg $c :TeamID"
puthelp "privmsg $c :TeamName"
puthelp "privmsg $c :TeamMembers"
puthelp "privmsg $c :TeamKeys"
puthelp "privmsg $c :TeamClicks"
puthelp "privmsg $c :TeamDescription"
puthelp "privmsg $c :TeamDateFormed"
}
}
|
I'm a total noob and i tried to read on about regsub an regexp the entire day but i still don't get any result so if anyone is able to help me, it would be greatly appreciated. Or gives me a few pointers in the right direction with how to separate each data field into its own variable.
Greetz ]x[ |
|
| Back to top |
|
 |
tsukeh Voice
Joined: 20 Jan 2005 Posts: 31
|
Posted: Sun Dec 02, 2007 6:41 am Post subject: |
|
|
| Code: |
package require http
bind pub - !test pulse_get
proc pulse_get {n u h c t} {
set x [::http::geturl http://whatpulse.org/api/user.php?UserID=223348]
set data [::http::data $x]
regexp -- {<AccountName>([^<]+)} $data {} AccountName
regexp -- {<Country>([^<]+)} $data {} Country
regexp -- {<DateJoined>([^<]+)} $data {} DateJoined
puthelp "privmsg $c :AccountName: $AccountName"
puthelp "privmsg $c :Country: $Country"
puthelp "privmsg $c :DateJoined: $DateJoined"
}
|
|
|
| Back to top |
|
 |
]x[ Voice
Joined: 09 Jan 2006 Posts: 14
|
Posted: Sun Dec 02, 2007 2:05 pm Post subject: |
|
|
OMG its working, thank you really much man. Now i can continue to fiddle and hopefully finish this script a bit more.
Thanks again and i really appreciate this. |
|
| Back to top |
|
 |
|