Closed Bonaf1de closed 2 years ago
I checked the code at work (can't run it in here, corporation policies), but problem is probably with parsing response using JSONPath.
Code: for i in allStats['result'][4]['entries'][1]['option']['options']: After fix: for i in allStats['result'][4]['entries'][0]['option']['options']:
On paper it should fix the problem.
Longer explanation: We send request to poe asking about possible affixes, etc... for items. Then we parse the result (named here allStats) using JSONpath with bracket notation. We need to go down the tree until we get to possible clusters enchantments (for example: "12% increased Attack Damage while Dual Wielding"). In original code we go to branch "1" of entries - before update it existed, now they changed a little response structure. Now we need to target "0" branch.
Different approach (but I would need to check it): allStats['result'][?(@.label=='Enchant')][..]['options'] -> will work only if [..] operator can be used or allStats['result'][?(@.label=='Enchant')][['options']]
That way we can be more flexible - if GGG changes the order of nodes we will be good because we don't target n-th node, but node with a specific label.
For more: https://requests.readthedocs.io/en/latest/user/quickstart/#json-response-content https://realpython.com/python-json/ https://blogboard.io/blog/knowledge/jsonpath-python/
responseStats = requests.get(
"https://www.pathofexile.com/api/trade/data/stats", headers=headers)
global allStats
allStats = responseStats.json()
allStats is a json, so we can use JSONPath syntax to traverse the tree and filter the content we are interested in.
By default we don't need to use .parse(jsonPath) - it can be simplified to allStats[][][][][]
Code: for i in allStats['result'][4]['entries'][1]['option']['options']: After fix: for i in allStats['result'][4]['entries'][0]['option']['options']:
This fixed it!!
I will fork repo, fix it and make a merge request.
Can you check if allStats['result'][?(@.label=='Enchant')][['options']] also works? I will check it in 3h if you don't have time :).
If I change:
for i in allStats['result'][4]['entries'][0]['option']['options']:
In:
for i in allStats['result'][?(@.label=='Enchant')][..]['options']:
Or:
for i in allStats['result'][?(@.label=='Enchant')][['options']]:
The python-script won't even start. But tbh I do not have faintest idea what I'm doing..
Thank you! I will work on it after work :). Enjoy!
śr., 5 paź 2022 o 15:18 Bonaf1de @.***> napisał(a):
If I change:
for i in allStats['result'][4]['entries'][0]['option']['options']:
In:
for i in @.***=='Enchant')][..]['options']:
Or:
for i in @.***=='Enchant')][['options']]:
The python-script won't even start. But tbh I do not have faintest idea what I'm doing..
— Reply to this email directly, view it on GitHub https://github.com/arturino009/POEcluster/issues/11#issuecomment-1268424060, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMM7BLHE7PV2KCL5WU7XP3WBV537ANCNFSM6AAAAAAQKSQJRY . You are receiving this because you commented.Message ID: @.***>
Its just so stupid from GGG. I have to change this shit almost every month. Why can't they just be consistent with the way they are sorting their stats
I don't have experience with Python, right now I work more with Java and .Net, but I think that we can make path to the nodes of interest more generic. I will try to work on it this weekend. Thank you for your work!
czw., 6 paź 2022 o 16:07 arturino009 @.***> napisał(a):
Its just so stupid from GGG. I have to change this shit almost every month. Why can't they just be consistent with the way they are sorting their stats
— Reply to this email directly, view it on GitHub https://github.com/arturino009/POEcluster/issues/11#issuecomment-1270118898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMM7BPIG3HDGUBMDUB6SQTWB3ML7ANCNFSM6AAAAAAQKSQJRY . You are receiving this because you commented.Message ID: @.***>
I made a fix. It can probably be better, but its good enough. Hopefully this will be enough for this specific issue
To my great regret the tool is stuk at updating:
And then: