Need help reading a web value

Previous topic - Next topic

ampos

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?

msx

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$.

Kitty Hello

Pay attention. It presents me a German page. So see if you can force the english output.
Netwebget$ should work fine.

ampos

It read your local language. On the bottom right you can change language.

Moru

#4
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.

ampos

#5
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)

Moru

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

ampos

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

Moru

Just about any web-browser can do this for you. Some needs plugins, others work straight off. Opera has it built-in.

MrTAToad

Wasn't there a routine somewhere in the forums that could read a JSON file ?

Moru

The problem here is to download the json in the first place. You need to do a post request, not a get.