GLBasic forum

Main forum => GLBasic - en => Topic started by: ampos on 2012-Sep-13

Title: Need help reading a web value
Post by: ampos on 2012-Sep-13
Hi! I need a bit help, if this can be done.

If you are used to Magic TG, you got a DCI ID. With this ID you can earn points playing Magic. To see your DCI points you enter at

http://www.wizards.com/Magic/PlaneswalkerPoints/

And enter your dci id

So the page http://www.wizards.com/Magic/PlaneswalkerPoints/2300205446 shows the points of player 2300205446. This info is not private but public.

I need a function

Score=get_dci(dci_id)

Where score is the seasonal score in this previous page. Anyone?
Title: Re: Need help reading a web value
Post by: msx on 2012-Sep-13
No se puede, ya que el navegador hace una petición por ajax al servidor una vez cargada la página, y eso no lo hace si lo leemos con NETWEBGET$.
Title: Need help reading a web value
Post by: Kitty Hello on 2012-Sep-13
Pay attention. It presents me a German page. So see if you can force the english output.
Netwebget$ should work fine.
Title: Re: Need help reading a web value
Post by: ampos on 2012-Sep-14
It read your local language. On the bottom right you can change language.
Title: Re: Need help reading a web value
Post by: Moru on 2012-Sep-14
Looks to me like you have to query this location (using NETWEBGET$ ofcourse):

http://www.wizards.com/Magic/PlaneswalkerPoints/JavaScript/GetPointsSummary/2300205446

You get some JSON encoded stuff back that is easy to parse out the number from:
Code (glbasic) Select
{"Result":true,"SessionExpired":false,"Data":[{"Key":"LifetimePoints","Value":29,"ReplaceElement":false},
{"Key":"Level","Value":6,"ReplaceElement":false},{"Key":"CurrentLevel","Value":6,"ReplaceElement":false},
{"Key":"NextLevel","Value":7,"ReplaceElement":false},{"Key":"PointsToNextLevel","Value":"1 points
away","ReplaceElement":false},{"Key":"Percentage","Value":0.8,"ReplaceElement":false},
{"Key":"Avatar","Value":"\u003cimg src=\"\" alt=\"\" /\u003e","ReplaceElement":false},
{"Key":"NamePlate","Value":"\u003cimg src=\"http://media.wizards.com/ContentResources/Magic/
PlaneswalkerPoints/LevelNames_4_en_US.png\" alt=\"\" /\u003e","ReplaceElement":false},{"Key":"Point","Value":"\r
\n    \u003cdiv class=\"HistoryPanelRow


Make sure you use NETWEBGET$ (with the $ at the end), not NETWEBGET(). The NETWEBGET$ downloads and save data in a string instead of saving in a file on your harddrive.
Title: Re: Need help reading a web value
Post by: ampos on 2012-Sep-15
Moru, thanks for your response, but this url returns an error on firefox, and in NETWEBGET$ I get this:

Code (glbasic) Select
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/Magic/PlaneswalkerPoints/Error">here</a>.</h2>
</body></html>


as I dont know how you get thi url, I dont know if it has changed...

I am using

Code (glbasic) Select
a$=NETWEBGET$("www.wizards.com","/Magic/PlaneswalkerPoints/JavaScript/GetPointsSummary/2300205446",80,52048,5000)
Title: Re: Need help reading a web value
Post by: Moru on 2012-Sep-16
Seems it is a POST request but with no data posted. Try Gernots tutorial for POST queries:
http://www.glbasic.com/forum/index.php?topic=2866.msg20989#msg20989
Title: Re: Need help reading a web value
Post by: ampos on 2012-Sep-19
Im sorry, but I can not understand Gernot post about POST queries.

How did you get the JSON text?

Code (glbasic) Select
{"Result":true,"SessionExpired":false,"Data":[{"Key":"LifetimePoints","Value":29,"ReplaceElement":false},
{"Key":"Level","Value":6,"ReplaceElement":false},{"Key":"CurrentLevel","Value":6,"ReplaceElement":false},
{"Key":"NextLevel","Value":7,"ReplaceElement":false},{"Key":"PointsToNextLevel","Value":"1&nbsp;points
away","ReplaceElement":false},{"Key":"Percentage","Value":0.8,"ReplaceElement":false},
{"Key":"Avatar","Value":"\u003cimg src=\"\" alt=\"\" /\u003e","ReplaceElement":false},
{"Key":"NamePlate","Value":"\u003cimg src=\"http://media.wizards.com/ContentResources/Magic/
PlaneswalkerPoints/LevelNames_4_en_US.png\" alt=\"\" /\u003e","ReplaceElement":false},{"Key":"Point","Value":"\r
\n    \u003cdiv class=\"HistoryPanelRow


I would love a program that gives me this JSON file/text
Title: Re: Need help reading a web value
Post by: Moru on 2012-Sep-19
Just about any web-browser can do this for you. Some needs plugins, others work straight off. Opera has it built-in.
Title: Re: Need help reading a web value
Post by: MrTAToad on 2012-Sep-19
Wasn't there a routine somewhere in the forums that could read a JSON file ?
Title: Re: Need help reading a web value
Post by: Moru on 2012-Sep-19
The problem here is to download the json in the first place. You need to do a post request, not a get.