It is currently March 29th, 2024, 8:13 am

Help with WebParser

Get help with creating, editing & fixing problems with skins
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Help with WebParser

Post by MaestroSky »

Please help me!
How do I add the resulting value from WebParser1 to the WebParser2 url?

Code: Select all

[InfoGM]
Measure=Plugin
Plugin=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/clanbattles/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=#ClanID#
UpdateRate=#UpdateTime#
RegExp=.*attack_type.*:.*,.*front_id.*:.*,.*front_name.*:.*,.*competitor_id.*:(.*),.*time.*:(.*),.*vehicle_level.*:.*,.*province_id.*:.*,.*type.*:(.*),.*province_name.*:(.*)"

[MeasureGMCompetitor]
Measure=Plugin
Plugin=WebParser
URL=[InfoGM]
StringIndex=1
Substitute="":"N/A" 

[InfoGMClan]
Measure=Plugin
Plugin=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=[&InfoGM]
UpdateRate=#UpdateTime#
RegExp=.*elo_10":(.*),.*elo_8.*,"name":(.*),"tag":(.*),.*private"

[MeasureGMElo_10]
Measure=Plugin
Plugin=WebParser
URL=[InfoGMClan]
StringIndex=1
Substitute="":"N/A"
When to add the URL to [InfoGMClan] .... URL=https://....._id=[&InfoGM]
It doesn't parse anything...

HELP ME!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with WebParser

Post by balala »

MaestroSky wrote: April 20th, 2021, 4:25 pm When to add the URL to [InfoGMClan] .... URL=https://....._id=[&InfoGM]
It doesn't parse anything...
I can't get your code working, probably because I don't have a good value for the ClanID variable, required in the URL option of the [InfoGM] measure, but I probably would tend to replace the [&InfoGM] section variable into the URL option of [InfoGMClan] measure with [&MeasureGMCompetitor], because [InfoGM] not having a StringIndex option set, probably is returning a large amount of information, which I doubt should be used into a URL.
Additionally (EXTREMELY IMPROTANT!) the [InfoGMClan] measure requires to add a DynamicVariables=1 option as well, because its URL option uses a section variable (either the original [&InfoGM], either, according to the above description, [&MeasureGMCompetitor], doesn't matter), which requires to set on the dyanmic variables.
If you can't get it to work and this is possible, please post the value of the ClanID variable, to can try out your code.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: Help with WebParser

Post by MaestroSky »

Code: Select all

[Variables]
@Include=#@#Settings.inc
fontName=Roboto Condensed
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205
ImageAlpha=100
ImageAlpha2=50
UpdateTime=3000
ClanID=422394   
;422394
;Последние 3 цифры ID Клана
ClanID3=418551
Discord=C:\Users\%UserName%\AppData\Local\Discord\Update.exe --processStart Discord.exe
WoT=D:\Games\World_of_Tanks_RU\WorldOfTanks.exe

[InfoGM]
Measure=Plugin
Plugin=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/clanbattles/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=#ClanID#
UpdateRate=#UpdateTime#
RegExp=.*attack_type.*:.*,.*front_id.*:.*,.*front_name.*:.*,.*competitor_id.*:(.*),.*time.*:(.*),.*vehicle_level.*:.*,.*province_id.*:.*,.*type.*:(.*),.*province_name.*:(.*)"
DynamicVariables=1

[MeasureGMCompetitor]
Measure=Plugin
Plugin=WebParser
URL=[InfoGM]
StringIndex=1
Substitute="":"N/A"

[MeasureGMTime]
Measure=Plugin
Plugin=WebParser
URL=[InfoGM]
StringIndex=2
Substitute="":"У клана нет назначеных боёв"

[MeasureGMType]
Measure=Plugin
Plugin=WebParser
URL=[InfoGM]
StringIndex=3
Substitute="":"N/A","attack":"Атака","defence":"Оборона"

[MeasureGMProvince]
Measure=Plugin
Plugin=WebParser
URL=[InfoGM]
StringIndex=4
Substitute="":"N/A"

[MeterGM]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureGMCompetitor
MeasureName2=MeasureTimeConvert
MeasureName3=MeasureGMType
MeasureName4=MeasureGMProvince
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
FontColor=255,255,255
AntiAlias=1
X=10
Y=25r
W=250
H=15
Text=Начало боев: %2
ToolTipType=1
ToolTipText=Тип:%3, Провинция:%4
Hidden=0

;Тег и название клана противника

[InfoGMClan]
Measure=Plugin
Plugin=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=[&InfoGM]
UpdateRate=#UpdateTime#
RegExp=.*elo_10":(.*),.*elo_8.*,"name":(.*),"tag":(.*),.*private"
DynamicVariables=1

[MeasureGMElo_10]
Measure=Plugin
Plugin=WebParser
URL=[InfoGMClan]
StringIndex=1
Substitute="":"N/A"

[MeasureGMName]
Measure=Plugin
Plugin=WebParser
URL=[InfoGMClan]
StringIndex=2
Substitute="":"N/A"

[MeasureGMTag]
Measure=Plugin
Plugin=WebParser
URL=[InfoGMClan]
StringIndex=3
Substitute="":"N/A"

[MeterGM2]
Meter=String
MeasureName=MeasureGMElo_10
MeasureName2=MeasureGMName
MeasureName3=MeasureGMTag
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
FontColor=255,255,255,120
AntiAlias=1
X=10
Y=25r
W=250
H=15
Text=Клан: %3, Elo:%1
ToolTipText=Название клана:%2
ToolTipType=1
Hidden=0
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with WebParser

Post by Yincognito »

MaestroSky wrote: April 20th, 2021, 4:25 pm Please help me!
How do I add the resulting value from WebParser1 to the WebParser2 url?

Code: Select all

[InfoGM]
Measure=Plugin
Plugin=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/clanbattles/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=#ClanID#
UpdateRate=#UpdateTime#
RegExp=.*attack_type.*:.*,.*front_id.*:.*,.*front_name.*:.*,.*competitor_id.*:(.*),.*time.*:(.*),.*vehicle_level.*:.*,.*province_id.*:.*,.*type.*:(.*),.*province_name.*:(.*)"

[MeasureGMCompetitor]
Measure=Plugin
Plugin=WebParser
URL=[InfoGM]
StringIndex=1
Substitute="":"N/A" 

[InfoGMClan]
Measure=Plugin
Plugin=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=[&InfoGM]
UpdateRate=#UpdateTime#
RegExp=.*elo_10":(.*),.*elo_8.*,"name":(.*),"tag":(.*),.*private"

[MeasureGMElo_10]
Measure=Plugin
Plugin=WebParser
URL=[InfoGMClan]
StringIndex=1
Substitute="":"N/A"
When to add the URL to [InfoGMClan] .... URL=https://....._id=[&InfoGM]
It doesn't parse anything...

HELP ME!
As Balala said, you need to:
- set the [InfoGMClan] URL to:

Code: Select all

URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=[&MeasureGMCompetitor]
- add a DynamicVariables=1 line to [InfoGMClan]

But also, you need to trigger the update of [InfoGMClan] from the FinishAction of [InfoGM], by adding to [InfoGM] the following:

Code: Select all

FinishAction=[!CommandMeasure InfoGMClan "Update"]
P.S. This is untested code, but it should work. If it doesn't, you can modify the FinishAction above to:

Code: Select all

FinishAction=[!SetOption InfoGMClan URL "https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=[&MeasureGMCompetitor]"][!CommandMeasure InfoGMClan "Update"]
The above should work even with the plain [MeasureGMCompetitor] in the SetOption, or even if [InfoGMClan] has an empty URL before this, since the modifications are done from the SetOption.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with WebParser

Post by Yincognito »

Forget what I said earlier, I just noticed from your skin code that you actually want to use the ClanID variable (aka 422394). Therefore, the solution is much simpler, just set your [InfoGMClan]'s URL to:

Code: Select all

URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=#ClanID#
This, and (optionally?) adding a DynamicVariables=1 line to the measures that need it, should be enough.

EDIT: It works with what I said in my previous post as well, but obviously it would provide the information for a different "competitor ID", and not a "clan ID" like you seem to want. I have no idea what's the difference between them, didn't play World of Tanks yet, though have friends who did. :D
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: Help with WebParser

Post by MaestroSky »

Yincognito wrote: April 20th, 2021, 6:28 pm Forget what I said earlier, I just noticed from your skin code that you actually want to use the ClanID variable (aka 422394). Therefore, the solution is much simpler, just set your [InfoGMClan]'s URL to:

Code: Select all

URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=#ClanID#
This, and (optionally?) adding a DynamicVariables=1 line to the measures that need it, should be enough.

EDIT: It works with what I said in my previous post as well, but obviously it would provide the information for a different "competitor ID", and not a "clan ID" like you seem to want. I have no idea what's the difference between them, didn't play World of Tanks yet, though have friends who did. :D
You have no idea how grateful I am to you. There is no limit to my joy. Everything works.
Thank you to everyone who responded to this problem and good luck. :thumbup: :great:
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with WebParser

Post by Yincognito »

MaestroSky wrote: April 20th, 2021, 7:40 pm You have no idea how grateful I am to you. There is no limit to my joy. Everything works.
Thank you to everyone who responded to this problem and good luck. :thumbup: :great:
Glad to help - have fun! ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with WebParser

Post by balala »

I had written my reply when you posted yours, so I'm posting this as well, if interested. Take into account especially to disable the [InfoGMClan] measure (second point), to avoid error messages in log.
MaestroSky wrote: April 20th, 2021, 4:25 pm HELP ME!
Final solution probably is between what Yincognito and I said. Here is what I mean: you probably have to:
  • Replace the URL of the [InfoGMClan] measure, by the following: URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=[&MeasureGMCompetitor] (see red what has been replaced).
  • Since when you're refreshing / loading the skin, the [MeasureGMCompetitor] measure doesn't have a value and it takes a while it to get the value (all WebParser measures needs a few seconds to get their values), add a Disabled=1 option to the [InfoGMClan] measure. With this you get it disabled when you're refreshing / loading the skin. To get it enabled when the [MeasureGMCompetitor] measure gets its value, you have to enable it throguh the FinishAction option, added to the [InfoGM] measure. In paralel, you have to update the [InfoGMClan] measure as well, to get it parsing the site. So, add the following FinishAction option to the [InfoGM] measure: FinishAction=[!EnableMeasure "InfoGMClan"][!CommandMeasure "InfoGMClan" "Update"].
With these updates, the code looks like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
@Include=#@#Settings.inc
fontName=Roboto Condensed
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205
ImageAlpha=100
ImageAlpha2=50
UpdateTime=3000
ClanID=422394   
;422394
;Последние 3 цифры ID Клана
ClanID3=418551
Discord=C:\Users\%UserName%\AppData\Local\Discord\Update.exe --processStart Discord.exe
WoT=D:\Games\World_of_Tanks_RU\WorldOfTanks.exe

[InfoGM]
Measure=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/clanbattles/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=#ClanID#
UpdateRate=#UpdateTime#
RegExp=.*attack_type.*:.*,.*front_id.*:.*,.*front_name.*:.*,.*competitor_id.*:(.*),.*time.*:(.*),.*vehicle_level.*:.*,.*province_id.*:.*,.*type.*:(.*),.*province_name.*:(.*)"
DynamicVariables=1
FinishAction=[!EnableMeasure "InfoGMClan"][!CommandMeasure "InfoGMClan" "Update"]

[MeasureGMCompetitor]
Measure=WebParser
URL=[InfoGM]
StringIndex=1
RegExpSubstitute=1
Substitute="^$":"N/A"

[MeasureGMTime]
Measure=WebParser
URL=[InfoGM]
StringIndex=2
RegExpSubstitute=1
Substitute="^$":"У клана нет назначеных боёв"

[MeasureGMType]
Measure=WebParser
URL=[InfoGM]
StringIndex=3
RegExpSubstitute=1
Substitute="^$":"N/A","attack":"Атака","defence":"Оборона"

[MeasureGMProvince]
Measure=WebParser
URL=[InfoGM]
StringIndex=4
RegExpSubstitute=1
Substitute="^$":"N/A"

[MeterGM]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureGMCompetitor
;MeasureName2=MeasureTimeConvert
MeasureName2=MeasureGMType
MeasureName3=MeasureGMProvince
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
FontColor=255,255,255
AntiAlias=1
X=10
Y=25r
W=250
H=15
Text=Начало боев: %2
ToolTipType=1
ToolTipText=Тип:%3, Провинция:%4
Hidden=0
SolidColor=0,0,0,1

;Тег и название клана противника

[InfoGMClan]
Measure=WebParser
URL=https://api.worldoftanks.ru/wot/globalmap/claninfo/?application_id=bf049cf6db102d4f0536904348d02500&clan_id=[&MeasureGMCompetitor]
UpdateRate=#UpdateTime#
RegExp=.*elo_10":(.*),.*elo_8.*,"name":(.*),"tag":(.*),.*private"
DynamicVariables=1
Disabled=1

[MeasureGMElo_10]
Measure=WebParser
URL=[InfoGMClan]
StringIndex=1
RegExpSubstitute=1
Substitute="^$":"N/A"

[MeasureGMName]
Measure=WebParser
URL=[InfoGMClan]
StringIndex=2
RegExpSubstitute=1
Substitute="^$":"N/A"

[MeasureGMTag]
Measure=WebParser
URL=[InfoGMClan]
StringIndex=3
RegExpSubstitute=1
Substitute="^$":"N/A"

[MeterGM2]
Meter=String
MeasureName=MeasureGMElo_10
MeasureName2=MeasureGMName
MeasureName3=MeasureGMTag
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
FontColor=255,255,255,120
AntiAlias=1
X=10
Y=25r
W=250
H=15
Text=Клан: %3, Elo:%1
ToolTipText=Название клана:%2
ToolTipType=1
Hidden=0
SolidColor=0,0,0,1
Note a few additional updates I did:
  • Added a DynamicWindowSize=1 option to the [Rainmeter] section (in fact I added the whole [Rainmeter] section, which hasn't been posted previuously).
  • Added a SolidColor=0,0,0,1 option to all the String meters, to get them easily clickable.
  • Replaced the Substitute="":"N/A" options with a RegExpSubstitute=1 and a Substitute="^$":"N/A" (on some measures, additional substitutes have been made, took them into account). This is needed, because this step tells clearly Rainmeter to substitute ONLY if the measure returns nothing (is empty).
  • Although a while ago WebParser indeed was a plugin, in meantime it has been converted to an internale measure. As such, you should not use the Measure=Plugin and Plugin=WebParser options pair, but should replace them with the simpler Measure=WebParser (obviously on all such measures). I did this as well.
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with WebParser

Post by Yincognito »

balala wrote: April 20th, 2021, 7:48 pmFinal solution probably is between what Yincognito and I said.
Yeah, unfortunately we misunderstood what he wanted the first time we replied, and his complete code helped (good idea to ask him that, by the way): he simply wanted to use the same #ClanID# variable for a second time, using a slightly different URL in the 2nd WebParser. He probably thought it would need something from the 1st WebParser to do that, but there was no need, as the ClanID variable was already declared/initialized with a hardcoded value in his [Variables] section. Bottom line, the "Competitor ID" was not needed for the 2nd WebParser - his full code reply made that clear.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: Help with WebParser

Post by MaestroSky »

Please tell me another such moment!
The resulting value in [MeasureGMCompetitor] can be different, for example: 125846 or 45876 they can have a different number of characters. How is it possible to extract only the last 3 characters?