|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
|
|
|
Edogg Beginner
Joined: 27 Feb 2011 Posts: 17
|
|
|
|
Edogg Beginner
Joined: 27 Feb 2011 Posts: 17
|
Posted: Sat Oct 08, 2016 2:42 am |
Notice the use of ~ in #script to bypass the typical zscript syntax
#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http://api.imperian.com/characters.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML) |
|
|
|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
Posted: Mon Oct 10, 2016 3:44 am |
Thanks, Edogg.. I'm working on the last bit but you almost got me there.
#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http://api.imperian.com/characters/dyron.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML)
Currently, trying to figure out how to make it so I can do an alias pull to change the characters name, like whois dyron would do http://api.imperian.com/characters/dyron.json
Then going to take that and be able to print something like Dyron(Outrider): Level 106 - Antioch |
|
|
|
Edogg Beginner
Joined: 27 Feb 2011 Posts: 17
|
Posted: Wed Nov 09, 2016 3:33 am |
Sorry Dyron been plenty busy,
As for the alias just create one named whois then put the additional line #var player %1 (player can be whatever you want to label it), then replace the name in the hyperlink with @player:
#var player %1
#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http://api.imperian.com/characters/@player.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML)
<alias name="whois" id="2457">
<value>#var player %1
#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http:~/~/api.imperian.com~/characters/@player.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML)
</value>
</alias>
you could even make the actually hyperlink a variable like so:
#var hyperlink http://api.imperian.com/characters/@player.json
then replace the code: objHTTP.Open ~"GET~", ~"http:~/~/api.imperian.com~/characters/@player.json?%time( hhnnss)~" with
objHTTP.Open ~"GET~", @hyperlink?%time( hhnnss)~"
As for pulling only some data out of this you could use triggers and gag it, when I get more time I can come up with a better solution |
|
|
|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
Posted: Wed Nov 09, 2016 3:48 am |
Thanks, Edogg..
Honestly, I had given up on it. Never could get anywhere.. Currently, I just do a whois and it pulls up the webpage direct.. Slower than I want but as much as I could get.
I just tried what you did and stored it in a variable but it stores all of it as one line.. Was really hoping it might give me a pull like gmcp. Going to try to fiddle with what you gave me a bit more..
As I said, thanks a ton. |
|
|
|
Edogg Beginner
Joined: 27 Feb 2011 Posts: 17
|
Posted: Sun Dec 04, 2016 3:14 am |
this works but is not the best, sorry I really don't know lua:
make an alias called whois
then put this in the body:
#var player %1
#var hyperlink "http://api.imperian.com/characters/"@player".json"
#lua {if not http then http = require("socket.http") end
local page = http.request(~"@hyperlink~")
wstart = string.find(page, "fullname", 0, true)
wend = string.find(page, "bashing_level", 0, true)
where = string.sub(page, wstart, wend - 1)
zs.print("\n")
zs.print("\027[1;37m"..where)
}
You should be able to type whois name
it will fail if the player name does not exist
this worked for me: http://postimg.org/image/tfsqhg50f/49313512/ |
|
|
|
|
|