It is currently April 19th, 2024, 10:29 am

Help with WebParser

Get help with creating, editing & fixing problems with skins
Savager35
Posts: 3
Joined: March 7th, 2020, 5:45 am

Help with WebParser

Post by Savager35 »

I am trying to make a rskin that displays the content from this url https://corona.lmao.ninja/all. I have been trying to display the data but cannot get it to work.

Here what I have

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=3
Background=#@#Background.png
BackgroundMargins=0,34,0,14

[Metadata]
Name=MineCorona
Author=Joe
Information=Displays the current date and time.
License=Creative Commons BY-NC-SA 3.0
Version=1.0.0


[Variables]
fontName=Minecraftia
textSize=8
colorBar=235,170,0,255
colorText=71,64,64,66

[MeasureSite]
Measure=WebParser
URL=https://corona.lmao.ninja/all
RegExp=(?siU)<pre style="word-wrap: break-word; white-space: pre-wrap;">"cases":</pre>.*<pre>(.*)</pre>
UpdateRate=3000


[MeasureChild1]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1

[MeterChild1]
Meter=String
MeasureName=MeasureChild1

;Date Measure and Meter
[measureDate]
Measure=Time
Format=%d.%m.%Y

[meterDate]
Meter=String
MeterStyle=styleRightText
MeasureName=measureDate
X=200
Y=0r
; r stands for relative. In this case, the Y postition of meterValueCPU is 0 pixels
; below the Y value of the previous meter (i.e it's the same as in meterLabelCPU).
W=190
H=14
Text=%1
;Date End

[styleTitle]
StringAlign=Center
StringCase=Upper
StringStyle=
StringEffect=
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=0
ClipString=1


[meterTitle]
MeterStyle=styleTitle
Meter=String
MeterStyle=MeasureChild1
X=100
Y=12
W=190
H=18
Text=MeasureChild1
If anyone could help i'd really appreciate it.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with WebParser

Post by balala »

Savager35 wrote: March 7th, 2020, 4:08 pm I am trying to make a rskin that displays the content from this url https://corona.lmao.ninja/all. I have been trying to display the data but cannot get it to work.

Here what I have If anyone could help i'd really appreciate it.
I tried, however it seems impossible, because after two or three tries, I got a This project has received too many requests, please try again later. message in my browser. Probably the number of connections is limited to a very low value.
First make sure you can connect. Try to open the URL (https://corona.lmao.ninja/all) in your browser. Does it opens?
Savager35
Posts: 3
Joined: March 7th, 2020, 5:45 am

Re: Help with WebParser

Post by Savager35 »

yeah I get the same thing, but when it does load it looks like this https://ibb.co/myQkKY6
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with WebParser

Post by Yincognito »

balala wrote: March 7th, 2020, 4:33 pmI tried, however it seems impossible, because after two or three tries, I got a This project has received too many requests, please try again later. message in my browser. Probably the number of connections is limited to a very low value. First make sure you can connect. Try to open the URL (https://corona.lmao.ninja/all) in your browser. Does it opens?
Savager35 wrote: March 7th, 2020, 4:39 pmyeah I get the same thing, but when it does load it looks like this: https://ibb.co/myQkKY6
Seems to work fine here (be aware that I modified the original posted code, cause it was a mess in some areas):

Code: Select all

[Variables]
FontName=Tahoma
TextSize=8
ColorBar=235,170,0,255
ColorText=71,255,64,255

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

;BackgroundMode=3
;Background=#@#Background.png
;BackgroundMargins=0,34,0,14

BackgroundMode=2
SolidColor=67,67,67,255

[Metadata]
Name=MineCorona
Author=Joe
Information=Displays the current date and time.
License=Creative Commons BY-NC-SA 3.0
Version=1.0.0

---Measures---

[MeasureSite]
Measure=WebParser
URL="https://corona.lmao.ninja/all"
RegExp="(?siU).*\{"cases":(.*),"deaths":(.*),"recovered":(.*)\}.*"
UpdateRate=600

[MeasureCases]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1

[MeasureDeaths]
Measure=WebParser
URL=[MeasureSite]
StringIndex=2

[MeasureRecovered]
Measure=WebParser
URL=[MeasureSite]
StringIndex=3

[MeasureDate]
Measure=Time
Format=%d.%m.%Y

---Styles---

---Meters---

[MeterTitle]
Meter=String
StringAlign=Left
StringCase=Upper
FontWeight=700
FontEffectColor=0,0,0,50
FontColor=#ColorText#
FontFace=#FontName#
FontSize=10
AntiAlias=1
ClipString=2
Padding=5,5,5,5
X=0
Y=0
Text="Mine Corona"
DynamicVariables=1

[MeterDate]
Meter=String
StringAlign=Right
StringCase=Proper
FontEffectColor=0,0,0,50
FontColor=#ColorText#
FontFace=#FontName#
FontSize=10
AntiAlias=1
ClipString=2
Padding=5,5,5,5
X=200
Y=0r
MeasureName=MeasureDate
Text="%1"

[MeterContent]
Meter=String
StringAlign=Center
StringCase=Proper
FontEffectColor=0,0,0,50
FontColor=#ColorText#
FontFace=#FontName#
FontSize=10
AntiAlias=1
ClipString=2
Padding=5,5,5,5
X=100
Y=0R
MeasureName=MeasureCases
MeasureName2=MeasureDeaths
MeasureName3=MeasureRecovered
Text="Cases: %1#CRLF#Deaths: %2#CRLF#Recovered: %3"
Feel free to modify it back, if you want. Didin't receive "too many requests" errors at all, by the way:
Mine Corona.jpg
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Savager35
Posts: 3
Joined: March 7th, 2020, 5:45 am

Re: Help with WebParser

Post by Savager35 »

Thanks man, I really appreciate it :)
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with WebParser

Post by Yincognito »

Savager35 wrote: March 7th, 2020, 5:37 pm Thanks man, I really appreciate it :)
You're welcome. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with WebParser

Post by balala »

Yincognito wrote: March 7th, 2020, 5:30 pm Seems to work fine here (be aware that I modified the original posted code, cause it was a mess in some areas):
Yep, now here as well. When I previously tried and posted my last reply, as I said, I got only a This project has received too many requests, please try again later. message in my browser. But now it indeed is working. Don't know what has happened in meantime, but if it is working (and it does for me now, as said), it's good.
Just note two minor details related to your code: This being said, here is how the [MeasureSite] measure should look like:

Code: Select all

[MeasureSite]
Measure=WebParser
URL=https://corona.lmao.ninja/all
RegExp=(?siU).*\{"cases":(.*),"deaths":(.*),"recovered":(.*)}.*
UpdateRate=600
Note that the posted measure as it is, works perfectly. But just to be precise, this had to be said.
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with WebParser

Post by Yincognito »

balala wrote: March 7th, 2020, 6:41 pmJust note two minor details related to your code: But just to be precise, this had to be said.
On quotes, I know that they don't have to be there. BUT including them in all string cases (even if there's no need for them) helps prevent further problems with spaces, if one modifies his code very often. For example, say you use an unquoted string variable in some measure, but in the process of coding, you come to a point where you need that variable in a RunCommand or variable featured regex Substitute (or in whatever case where you need to consider handling spaces with care). Having already the quotes helps you avoid situations in which your code doesn't work and you need a half an hour or more (and the corresponding nerves, LOL) to realize it was because of a minor problem like the fact that you didn't enclose your string in quotes. Bottom line, enclosing a string in quotes never hurts, but not enclosing it in quotes can hurt. So, I won't follow your advice on this one, if you don't mind... :D

On regex reserved characters, you're probably right. However, since they are brackets and most of the rest of the brackets (e.g. round, square) have to be escaped, I made a habit of escaping the curled ones (basically, every bracket I see) as well. Just like above, it doesn't hurt if escaped, but it can hurt if not (and then, say, changed into another bracket). So, I'm really sorry to disapoint you this time, my friend, but despite the fact that they are technically correct and I appreciate you gave them, I won't follow any advice you gave in this post - simply because doing like I do now helps alleviate potential practical problems. I'd rather "torture" myself with the small task of adding quotes and backslashes in some places where they're not really needed, than going crazy due to something not working because of a damn quote or backslash that I missed... ;-)
balala wrote: March 7th, 2020, 6:41 pmYep, now here as well. When I previously tried and posted my last reply, as I said, I got only a This project has received too many requests, please try again later. message in my browser. But now it indeed is working. Don't know what has happened in meantime...
I'll tell you what happened: they found out Yincognito needed his sample skin to work, and they quickly solved the issue. :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with WebParser

Post by balala »

Yincognito wrote: March 7th, 2020, 8:01 pm On quotes, I know that they don't have to be there. BUT including them in all string cases (even if there's no need for them) helps prevent further problems with spaces, if one modifies his code very often.
No, in fact they are not, because Rainmeter simply ignores them. In fact, it even ignores them in Substitute options (!!!!!). For instance both the Substitute="One":"1" as well as Substitute=One":"1 are working.
But yes, using them, doesn't hurt.
Yincognito wrote: March 7th, 2020, 8:01 pm So, I won't follow your advice on this one, if you don't mind...
No, I never. Anyone here (and anywhere) is free not to follow any of my (or anyone) advice.
Yincognito wrote: March 7th, 2020, 8:01 pm So, I'm really sorry to disapoint you this time,
No, don't be. You're not disappointing me at all. There are no ways to disappoint me here on this forum.
Yincognito wrote: March 7th, 2020, 8:01 pm I'll tell you what happened: they found out Yincognito needed his sample skin to work, and they quickly solved the issue. :lol:
Good point! :thumbup: :great: