It is currently May 18th, 2021, 11:51 pm

Help with parsing html

Help with creating, editing & fixing problems with skins
TimmyT1983
Posts: 12
Joined: December 22nd, 2020, 10:39 pm

Re: Help with parsing html

Post by TimmyT1983 »

That code you posted is completely different from what you posted originally, so the regexp isn't going to work
Yeah, I assume what I originally posted was the browser's processed version of the javascript into html. After using the IP address directly with RainRegExp, I got the "raw" non processed javascript version of the page and that's why trying to parse didn't work and probably wont work because it's javascript or json :confused:

Does that make sense?

here is exactly what I get from RainRegExp:

Code: Select all

<!DOCTYPE html><html lang=\“en\“ class=""><head><meta charset='utf-8'><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><title>Tasmota - Main Menu</title><script>var x=null,lt,to,tp,pc='';function eb(s){return document.getElementById(s);}function qs(s){return document.querySelector(s);}function sp(i){eb(i).type=(eb(i).type==='text'?'password':'text');}function wl(f){window.addEventListener('load',f);}function la(p){var a='';if(la.arguments.length==1){a=p;clearTimeout(lt);}if(x!=null){x.abort();}x=new XMLHttpRequest();x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){var s=x.responseText.replace(/{t}/g,"<table style='width:100%'>").replace(/{s}/g,"<tr><th>").replace(/{m}/g,"</th><td>").replace(/{e}/g,"</td></tr>").replace(/{c}/g,"%'><div style='text-align:center;font-weight:");eb('l1').innerHTML=s;}};x.open('GET','.?m=1'+a,true);x.send();lt=setTimeout(la,2345);}function lc(v,i,p){if(eb('s')){if(v=='h'||v=='d'){var sl=eb('sl4').value;eb('s').style.background='linear-gradient(to right,rgb('+sl+'%,'+sl+'%,'+sl+'%),hsl('+eb('sl2').value+',100%,50%))';}}la('&'+v+i+'='+p);}wl(la);function jd(){var t=0,i=document.querySelectorAll('input,button,textarea,select');while(i.length>=t){if(i[t]){i[t]['name']=(i[t].hasAttribute('id')&&(!i[t].hasAttribute('name')))?i[t]['id']:i[t]['name'];}t++;}}wl(jd);</script><style>div,fieldset,input,select{padding:5px;font-size:1em;}fieldset{background:#4f4f4f;}p{margin:0.5em 0;}input{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;background:#dddddd;color:#000000;}input[type=checkbox],input[type=radio]{width:1em;margin-right:6px;vertical-align:-1px;}input[type=range]{width:99%;}select{width:100%;background:#dddddd;color:#000000;}textarea{resize:vertical;width:98%;height:318px;padding:5px;overflow:auto;background:#1f1f1f;color:#65c115;}body{text-align:center;font-family:verdana,sans-serif;background:#252525;}td{padding:0px;}button{border:0;border-radius:0.3rem;background:#1fa3ec;color:#faffff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:0.4s;transition-duration:0.4s;cursor:pointer;}button:hover{background:#0e70a4;}.bred{background:#d43535;}.bred:hover{background:#931f1f;}.bgrn{background:#47c266;}.bgrn:hover{background:#5aaf6f;}a{color:#1fa3ec;text-decoration:none;}.p{float:left;text-align:left;}.q{float:right;text-align:right;}.r{border-radius:0.3em;padding:2px;margin:6px 2px;}</style></head><body><div style='text-align:left;display:inline-block;color:#eaeaea;min-width:340px;'><div style='text-align:center;color:#eaeaea;'><noscript>To use Tasmota, please enable JavaScript<br></noscript><h3>Sonoff TH Module</h3><h2>Tasmota</h2></div><div id='l1' name='l1'></div><table style='width:100%'><tr><td style='width:100%'><button onclick='la("&o=1");'>Toggle</button></td></tr></table><div></div><p><form action='cn' method='get'><button>Configuration</button></form></p><p><form action='in' method='get'><button>Information</button></form></p><p><form action='up' method='get'><button>Firmware Upgrade</button></form></p><p><form action='cs' method='get'><button>Console</button></form></p><p><form action='.' method='get' onsubmit='return confirm("Confirm Restart");'><button name='rst' class='button bred'>Restart</button></form></p><div style='text-align:right;font-size:11px;'><hr/><a href='https://bit.ly/tasmota' target='_blank' style='color:#aaa;'>Tasmota 9.1.0 by Theo Arends</a></div></div></body></html>

There is another method to get the data (in another part of the server) but it's also not html, just plain text and this I what I get:

Code: Select all

{"StatusSNS":{"Time":"2020-12-23T04:05:36","SI7021":{"Temperature":79.0,"Humidity":30.8,"DewPoint":45.5},"TempUnit":"F"}}
I assume that's mqtt
User avatar
SilverAzide
Rainmeter Sage
Posts: 1251
Joined: March 23rd, 2015, 5:26 pm

Re: Help with parsing html

Post by SilverAzide »

Yeah, the first thing is HTML, but the page is being rendered with Javascript so it's useless (your data isn't in there from what I can see). But that second text can be easily parsed. Is that data the exact return value?
Gadgets Wiki GitHub More Gadgets...
TimmyT1983
Posts: 12
Joined: December 22nd, 2020, 10:39 pm

Re: Help with parsing html

Post by TimmyT1983 »

The second text is the exact return value, no html, just that text. I ended up getting everything from that return value (unparsed) displayed in rainmeter but if you know how to parse and display it i'm interested!
User avatar
SilverAzide
Rainmeter Sage
Posts: 1251
Joined: March 23rd, 2015, 5:26 pm

Re: Help with parsing html

Post by SilverAzide »

TimmyT1983 wrote: December 24th, 2020, 12:49 am The second text is the exact return value, no html, just that text. I ended up getting everything from that return value (unparsed) displayed in rainmeter but if you know how to parse and display it i'm interested!
I'm not all that savvy at regexps, but try the following in your main [MeasureSite] measure:

Code: Select all

RegExp=(?siU){.*{.*:"(.*)".*:{".*":(.*),.*:(.*),.*:(.*)},.*:"(.*)"}}
The captures should look like this:

1 => 2020-12-23T04:05:36
2 => 79.0
3 => 30.8
4 => 45.5
5 => F

So just set the index on the child WebParser measures to whichever data items you want. I just guessed at what you are looking to return, you can grab anything in that string that you want.
Gadgets Wiki GitHub More Gadgets...
User avatar
Youkai1977
Posts: 139
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

I hope I may hang myself with my problem here simply times ... :) :oops:

I am editing the WebParser-Measure of my NewsFeed-Skin.
I would like to add the RegEx that the <lastBuildDate> is read, as well as optimize the RegEx in general, as it can be read here -> https://docs.rainmeter.net/tips/rss-feed-tutorial/.
I would like to read out the <lastBuildDate> at the portal "GOOGLE NEWS" https://news.google.com/rss?pz=1&cf=all&hl=de&gl=DE&ceid=DE:de.

I have now read through various help on the net to the RegEx to this, but I must admit to myself, this is too high for me. I am not stupid, but that ... no plan. O.O :???:
What confuses me above all is that if I use in the net e.g. RegEx-Generators, these tell me then, I have it correctly, it does NOT work however if I try this then in the Program RainRegExp, then an error receives.
In short, for laymen really not easy to look through it.

Simple is that if I want to have the whole string. Then it needs only <lastBuildDate>(.*)</lastBuildDate>.
But I do NOT want the whole string, but ONLY: "Example:" 30 Mar 09:55:35

The Tue, as well as the GMT should be filtered out.

I have it now thanks to RainRegExp so <lastBuildDate>.*(.{0,21})...</lastBuildDate> and the result is as desired ... so ONLY 30 Mar 09:55:35 instead of Tue, 30 Mar 09:55:35 GMT.
But I'm getting the feeling like I've solved it too complicated. :uhuh:
Am I right with my suspicion, or do I have it (according to the motto, a blind hen also finds a grain) actually right?
RegEx-Example.png
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 12670
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: March 30th, 2021, 11:47 am Simple is that if I want to have the whole string. Then it needs only <lastBuildDate>(.*)</lastBuildDate>.
But I do NOT want the whole string, but ONLY: "Example:" 30 Mar 09:55:35
I'd get the date and time as is it returned by the site, then would use a Time measure, to can convert the date and time to any desired format.
Here is an example. I used an extremely simple WebParser measure:

Code: Select all

[MeasureRainmeter]
Measure=WebParser
UpdateRate=870
Url=https://news.google.com/rss?pz=1&cf=all&hl=de&gl=DE&ceid=DE:de
RegExp=(?siU)<lastBuildDate>(.*)</lastBuildDate>
FinishAction=[!EnableMeasure "MeasureLastBuildwFormated"][!UpdateMeasure "MeasureLastBuildwFormated"]
DecodeCharacterReference=3
StringIndex=1
As you can see, the FinishAction option of this measure is enabling and updating a measure called [MeasureLastBuildwFormated], which has not been posted so far. So add it:

Code: Select all

[MeasureLastBuildwFormated]
Measure=Time
Format=%d %b %H:%M:%S
TimeStamp=[MeasureRainmeter]
TimeStampFormat=%a, %d %b %Y %H:%M:%S GMT
DynamicVariables=1
Disabled=1
See that this measure is a disabled Time measure. It has to be disabled to avoid the error messages in the log. When the [MeasureRainmeter] parent WebParser measure gets its value, the FinishAction option enables and updates the [MeasureLastBuildwFormated], so you get the appropriate result retuned by this measure.
Obviously you can freely modify the Format option of the measure, to get the appropriate format.
User avatar
Youkai1977
Posts: 139
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

balala wrote: March 30th, 2021, 6:20 pm I'd get the date and time as is it returned by the site, then would use a Time measure, to can convert the date and time to any desired format.
Here is an example. I used an extremely simple WebParser measure:

Code: Select all

[MeasureRainmeter]
Measure=WebParser
UpdateRate=870
Url=https://news.google.com/rss?pz=1&cf=all&hl=de&gl=DE&ceid=DE:de
RegExp=(?siU)<lastBuildDate>(.*)</lastBuildDate>
FinishAction=[!EnableMeasure "MeasureLastBuildwFormated"][!UpdateMeasure "MeasureLastBuildwFormated"]
DecodeCharacterReference=3
StringIndex=1
As you can see, the FinishAction option of this measure is enabling and updating a measure called [MeasureLastBuildwFormated], which has not been posted so far. So add it:

Code: Select all

[MeasureLastBuildwFormated]
Measure=Time
Format=%d %b %H:%M:%S
TimeStamp=[MeasureRainmeter]
TimeStampFormat=%a, %d %b %Y %H:%M:%S GMT
DynamicVariables=1
Disabled=1
See that this measure is a disabled Time measure. It has to be disabled to avoid the error messages in the log. When the [MeasureRainmeter] parent WebParser measure gets its value, the FinishAction option enables and updates the [MeasureLastBuildwFormated], so you get the appropriate result retuned by this measure.
Obviously you can freely modify the Format option of the measure, to get the appropriate format.
Hi, Thanks for your tip / idea. :thumbup:

Almost exactly so I had it yesterday in my skin also already in had.
But I noticed that the timestamp is manipulated by the TIME-Measure in the output.

EXAMPLE:
<LastBuildDate> has the Time-Value 05:49:33 and the REAL current time is, say 07:59:18.
Then the result will show 05:59:18.

So the hour of <LastBuildDate> 5, but the minutes and seconds 59:18 of the real current time.

And if I do it as in your tip (which as I said is very similar to my implementation yesterday), I have EXACTLY the same problem.

See the Screenshots:
Unbenannt.png
Unbenannt2.png
LAST NFR-UPD: is the Time who the Skin ist Updated per [mRSS]-Measure (my other Problem from the other Thread ...you now?!)
LAST NFP-BUILD: Is the Time from the Website when the Time-Measure manipulated the <lastBuildDate>

But i don`t now why? :???: :confused: :uhuh:
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 12670
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: April 1st, 2021, 6:10 am EXAMPLE:
<LastBuildDate> has the Time-Value 05:49:33 and the REAL current time is, say 07:59:18.
Then the result will show 05:59:18.

So the hour of <LastBuildDate> 5, but the minutes and seconds 59:18 of the real current time.
This is a little bit weird, but I suppose your code is manipulating somehow the time. Please post the whole code, to can see what's going on there.
User avatar
Youkai1977
Posts: 139
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

balala wrote: April 1st, 2021, 5:18 pm This is a little bit weird, but I suppose your code is manipulating somehow the time. Please post the whole code, to can see what's going on there.
That this is a little strange, I can only agree. But so it goes me since the end of January yes soon with every skin I have since then started to code. Nothing works more on the first go. :uhuh:

But well, here is the code...

1.) newsfeed.ini

Code: Select all

[Rainmeter]
Update=20
DefaultUpdateDivider=50
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=NewsFeed Reader (Marquee)
Author=Youkai1977 
Version=03-21.V1 <> 30.03.2021
Information=This Meter is a Part of M.A.R.S.- 2021 Skin Package
License=Creative Commons Attribution-Non-Commercial-Share Alike 4.0

;==================================================
;=== VARIABLES & STYLES ===========================
;==================================================

[Variables]
@include=newsfeeddata.inc

;==============================================================
;=== VOICE OUTPUT =============================================
;==============================================================
;===                                                         ==
;=== FOR MORE INFO TO SPEECH-PLUGIN                          ==
;=== https://forum.rainmeter.net/viewtopic.php?f=127&t=31161 ==
;===                                                         ==
;==============================================================

[VoiceOutput]
Measure=PLUGIN
Plugin=Speech
Name=#VoiceName#
;Index=#IndexName# 
;Gender=#VoiceGender#
Debug=#DebugModus#
Volume=#VoiceVolume#
Rate=#SpeechRate#
UpdateDivider=-1

;==================================================
;=== MEASURES NEWS FEED & MARQUEE =================
;==================================================

;=== MEASURES NEWS FEED ===========================

[mRSS]
Measure=WEBPARSER
URL=#RSSUrl#
RegExp=(?siU)<lastBuildDate>(.*)</lastBuildDate>.*<description>(.*)</description>#NF1#(?(?=.*<item)#NF2##NF3##NF4##NF5#)
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
DecodeCharacterReference=3
UpdateRate=1200
StringIndex=1
Debug=1
OnChangeAction=[!EnableMeasureGroup mCHILDS][!UpdateMeasure mNFRUpdateTime][!SetOption HEADNAME FontColor "#Color4##Alpha1#"][!UpdateMeter HEADNAME][!ShowMeter HEADNAME][!UpdateMeterGroup FEED][!Redraw]
FinishAction=[!EnableMeasure mLBTSF][!UpdateMeasure mLBTSF][!UpdateMeterGroup FEED][!Redraw][!CommandMeasure VoiceOutput "#NewsUpdSpeech#"][!ShowMeter NewsFeed][!EnableMeasure mXPos][!UpdateMeasure mXPos][!Delay 4000][!SetOption HEADNAME FontColor "#Color3##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]

[mRSSNPN]
Measure=WEBPARSER
URL=[mRSS]
StringIndex=2
Disabled=1
Group=mCHILDS

[mRSSItem1]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=3
Disabled=1
Group=mCHILDS

[mRSSItem2]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=4
Disabled=1
Group=mCHILDS

[mRSSItem3]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=5
Disabled=1
Group=mCHILDS

[mRSSItem4]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=6
Disabled=1
Group=mCHILDS

[mRSSItem5]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=7
Disabled=1
Group=mCHILDS

;=== MEASURE NFR-SKIN-UPDATE TIME STAMP (mNFRUT) ==
;=== MEASURE NFR-SITE-BUILD  TIME STAMP (mLBTSF) ==

[mNFRUT]
Measure=TIME
Format=%d.%m.%Y [\x00B7] %H:%M:%S
TimeStampLocale=#TSL#
FormatLocale=#FL#
UpdateDivider=-1
Disabled=1
Group=mCHILDS

[mLBTSF]
Measure=TIME
Format=%d.%m.%Y [\x00B7] %H:%M:%S
TimeStamp=[mRSS]
TimeStampFormat=%a, %d %b %Y %H:%M:%S GMT
DynamicVariables=1
Disabled=1

;=== MEASURE MARQUEE FUNCTION =====================

[mXPos]
Measure=LOOP
StartValue=#StartPos#
EndValue=-[NewsFeed:W]
Increment=#Direction#
LoopCount=0
DynamicVariables=1
UpdateDivider=1
Disabled=1

;##################################################
;##################################################
;##################################################
;##################################################
;##################################################
;##################################################

;==================================================
;=== LAYER POS. & LAST NFR-UPD LINE ===============
;==================================================

[LAYERxPosText]
Meter=STRING
MeterStyle=StLAYER
X=0
Y=0

[NFRUpdText]
Meter=STRING
MeterStyle=StNFRUPDATE
X=200
Y=r

;==================================================
;=== HEAD NEWS FEED READER (Side Lines) ===========
;==================================================

[HEADLINES]
Meter=SHAPE
X=0
Y=20
Shape=Rectangle 0,0,8,8 | Extend ModifiersS1
Shape2=Line 8,4,26,4 | Extend ModifiersL1
Shape3=Rectangle 26,0,8,8 | Extend ModifiersS1
;-----
Shape4=Rectangle 0,16,8,8 | Extend ModifiersS2
Shape5=Line 8,20,26,20 | Extend ModifiersL2
Shape6=Rectangle 26,16,8,8 | Extend ModifiersS2
;-----
Shape7=Rectangle ([HEADNAME:W] + 48),0,8,8 | Extend ModifiersS1
Shape8=Rectangle ([HEADNAME:W] + 48),0,8,8 | Extend ModifiersS1
Shape9=Rectangle ([HEADNAME:W] + 48),16,8,8 | Extend ModifiersS2
Shape10=Rectangle ([HEADNAME:W] + 48),16,8,8 | Extend ModifiersS2
;-----
Shape11=Rectangle 872,0,8,8 | Extend ModifiersS1
Shape12=Line 854,4,872,4 | Extend ModifiersL1
Shape13=Rectangle 846,0,8,8 | Extend ModifiersS1
;-----
Shape14=Rectangle 872,16,8,8 | Extend ModifiersS2
Shape15=Line 854,20,872,20 | Extend ModifiersL2
Shape16=Rectangle 846,16,8,8 | Extend ModifiersS2
ModifiersS1=StrokeWidth 0 | Fill Color #Color3##Alpha2#
ModifiersL1=StrokeWidth 2 | StrokeColor #Color3##Alpha2#
ModifiersS2=StrokeWidth 0 | Fill Color #Color3##Alpha1#
ModifiersL2=StrokeWidth 2 | StrokeColor #Color3##Alpha1#
DynamicVariables=1
UpdateDivider=-1
Group=FEED

[HEADNAME]
Meter=STRING
MeterStyle=StHEAD
X=41
Y=r
MouseOverAction=[!SetOption HEADNAME FontColor "#Color4##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]
MouseLeaveAction=[!SetOption HEADNAME FontColor "#Color3##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]
LeftMouseUpAction=[#vURL#]

;==================================================
;=== MARQUEE NEWS FEED READER =====================
;==================================================

;=== CONTAINER NEWS FEED ==========================

[CONTAINER_NFR]
Meter=SHAPE
X=0
Y=r
Shape=Line ([HEADNAME:W] + 63),0,839,0 | StrokeWidth 47 | StrokeColor #Color0##Alpha1#
DynamicVariables=1
UpdateDivider=-1
LeftMouseDoubleClickAction=[#vURL#]
Group=FEED

;=== MARQUEE NEWS FEED ============================

[NewsFeed]
Meter=STRING
MeterStyle=StNEWS
X=[mXPos]r
Y=r
2.) newsfeeddata.inc

Code: Select all

[Variables]
;********************************************************************************************************************************************************
;********************************************************************************************************************************************************
;***                                                                                                                                               ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;***                                                                                                                                               ******
;********************************************************************************************************************************************************
;********************************************************************************************************************************************************
;==================================================
;=== VARIABLES FONTFACE - SIZE - COLORS ===========
;==================================================
FontFace=SQUARE721 BT
FS1=10
FS2=8
Alpha0=1
Alpha1=255
Alpha2=70
Color0=0,0,0,
Color1=160,246,253,
Color2=48,180,200,
Color3=97,240,255,
Color4=253,193,0,
Color5=255,255,255
Color6=255,104,67,
;==================================================
;=== VARIABLES SPEECH PLUGIN (NewsFeed) ===========
;==================================================
VoiceName=Microsoft Hedda Desktop
;IndexName= 
;VoiceGender=
DebugModus=0
VoiceVolume=100
SpeedRate=-2
NewsUpdSpeech=News Feed aktualisiert
;==================================================
;=== VARIABLES NEWS FEED READER ===================
;==================================================
Direction=-1
StartPos=850
RSSUrl=https://news.google.com/rss?pz=1&cf=all&hl=de&gl=DE&ceid=DE:de
vURL=http://news.google.de/
NF1=.*<item.*<title.*>(.*)</title>.*
NF2=.*<title.*>(.*)</title>
NF3=.*<title.*>(.*)</title>
NF4=.*<title.*>(.*)</title>
NF5=.*<title.*>(.*)</title>
TSL=de-DE
FL=de-DE
;==================================================
;=== STYLE NEWS FEED HEAD (Side Line) =============
;==================================================

[StLAYER]
Padding=0,-3,-1,-3
SolidColor=#Color0##Alpha0#
FontColor=#Color1##Alpha1#
FontFace=#FontFace#
FontSize=#FS2#
StringCase=UPPER
AntiAlias=1
Text=LAYER NFR   POS: [NewsFeed:Y] [\x00B7] [mXPos]
InlineSetting=Color | #Color6##Alpha1#
InlinePattern=[NewsFeed:Y]
InlineSetting2=Color | #Color4##Alpha1#
InlinePattern2=[\x00B7](.*)
DynamicVariables=1
UpdateDivider=1
Group=FEED

[StNFRUPDATE]
Padding=0,-3,-1,-3
SolidColor=#Color0##Alpha0#
FontColor=#Color1##Alpha1#
FontFace=#FontFace#
FontSize=#FS2#
StringCase=UPPER
AntiAlias=1
Text=LAST NFR-UPD: [mNFRUT] [\x2022] LAST NFP-BUILD: [mLBTSF]
InlineSetting=Color | #Color6##Alpha1#
InlinePattern=[mNFRUT] | [mLBTSF]
DynamicVariables=1
UpdateDivider=-1
Group=FEED

[StHEAD]
Padding=0,4,-1,5
SolidColor=#Color0##Alpha0#
FontColor=#Color3##Alpha1#
FontFace=#FontFace#
FontSize=#FS1#
StringCase=UPPER
AntiAlias=1
Text=[mRSSNPN]
ClipString=2
ClipStringW=105
ClipStringH=15
DynamicVariables=1
UpdateDivider=-1
Hidden=1

;==================================================
;=== STLYE NEWS FEED ==============================
;==================================================

[StNEWS]
Padding=0,4,-1,5
SolidColor=#Color0##Alpha0#
FontColor=#Color5##Alpha1#
FontFace=#FontFace#
FontSize=#FS1#
StringCase=UPPER
AntiAlias=1
Text=[\x2022][\x2022][\x2022]  [mRSSItem1]  [\x2022][\x2022][\x2022]  [mRSSItem2]  [\x2022][\x2022][\x2022]  [mRSSItem3]  [\x2022][\x2022][\x2022]  [mRSSItem4]  [\x2022][\x2022][\x2022]  [mRSSItem5]  [\x2022][\x2022][\x2022] 
InlineSetting=Color | #Color1##Alpha1#
InlinePattern=(?i)[mRSSItem1] | (?i)[mRSSItem3] | (?i)[mRSSItem5]
InlineSetting2=Color | #Color2##Alpha1#
InlinePattern2=(?i)[mRSSItem2] | (?i)[mRSSItem4]
DynamicVariables=1
UpdateDivider=1
Hidden=1
Container=CONTAINER_NFR
Group=FEED
User avatar
balala
Rainmeter Sage
Posts: 12670
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: April 2nd, 2021, 5:48 am But well, here is the code...

1.) newsfeed.ini

Code: Select all

[Rainmeter]
Update=20
DefaultUpdateDivider=50
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=NewsFeed Reader (Marquee)
Author=Youkai1977 
Version=03-21.V1 <> 30.03.2021
Information=This Meter is a Part of M.A.R.S.- 2021 Skin Package
License=Creative Commons Attribution-Non-Commercial-Share Alike 4.0

;==================================================
;=== VARIABLES & STYLES ===========================
;==================================================

[Variables]
@include=newsfeeddata.inc

;==============================================================
;=== VOICE OUTPUT =============================================
;==============================================================
;===                                                         ==
;=== FOR MORE INFO TO SPEECH-PLUGIN                          ==
;=== https://forum.rainmeter.net/viewtopic.php?f=127&t=31161 ==
;===                                                         ==
;==============================================================

[VoiceOutput]
Measure=PLUGIN
Plugin=Speech
Name=#VoiceName#
;Index=#IndexName# 
;Gender=#VoiceGender#
Debug=#DebugModus#
Volume=#VoiceVolume#
Rate=#SpeechRate#
UpdateDivider=-1

;==================================================
;=== MEASURES NEWS FEED & MARQUEE =================
;==================================================

;=== MEASURES NEWS FEED ===========================

[mRSS]
Measure=WEBPARSER
URL=#RSSUrl#
RegExp=(?siU)<lastBuildDate>(.*)</lastBuildDate>.*<description>(.*)</description>#NF1#(?(?=.*<item)#NF2##NF3##NF4##NF5#)
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
DecodeCharacterReference=3
UpdateRate=1200
StringIndex=1
Debug=1
OnChangeAction=[!EnableMeasureGroup mCHILDS][!UpdateMeasure mNFRUpdateTime][!SetOption HEADNAME FontColor "#Color4##Alpha1#"][!UpdateMeter HEADNAME][!ShowMeter HEADNAME][!UpdateMeterGroup FEED][!Redraw]
FinishAction=[!EnableMeasure mLBTSF][!UpdateMeasure mLBTSF][!UpdateMeterGroup FEED][!Redraw][!CommandMeasure VoiceOutput "#NewsUpdSpeech#"][!ShowMeter NewsFeed][!EnableMeasure mXPos][!UpdateMeasure mXPos][!Delay 4000][!SetOption HEADNAME FontColor "#Color3##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]

[mRSSNPN]
Measure=WEBPARSER
URL=[mRSS]
StringIndex=2
Disabled=1
Group=mCHILDS

[mRSSItem1]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=3
Disabled=1
Group=mCHILDS

[mRSSItem2]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=4
Disabled=1
Group=mCHILDS

[mRSSItem3]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=5
Disabled=1
Group=mCHILDS

[mRSSItem4]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=6
Disabled=1
Group=mCHILDS

[mRSSItem5]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=7
Disabled=1
Group=mCHILDS

;=== MEASURE NFR-SKIN-UPDATE TIME STAMP (mNFRUT) ==
;=== MEASURE NFR-SITE-BUILD  TIME STAMP (mLBTSF) ==

[mNFRUT]
Measure=TIME
Format=%d.%m.%Y [\x00B7] %H:%M:%S
TimeStampLocale=#TSL#
FormatLocale=#FL#
UpdateDivider=-1
Disabled=1
Group=mCHILDS

[mLBTSF]
Measure=TIME
Format=%d.%m.%Y [\x00B7] %H:%M:%S
TimeStamp=[mRSS]
TimeStampFormat=%a, %d %b %Y %H:%M:%S GMT
DynamicVariables=1
Disabled=1

;=== MEASURE MARQUEE FUNCTION =====================

[mXPos]
Measure=LOOP
StartValue=#StartPos#
EndValue=-[NewsFeed:W]
Increment=#Direction#
LoopCount=0
DynamicVariables=1
UpdateDivider=1
Disabled=1

;##################################################
;##################################################
;##################################################
;##################################################
;##################################################
;##################################################

;==================================================
;=== LAYER POS. & LAST NFR-UPD LINE ===============
;==================================================

[LAYERxPosText]
Meter=STRING
MeterStyle=StLAYER
X=0
Y=0

[NFRUpdText]
Meter=STRING
MeterStyle=StNFRUPDATE
X=200
Y=r

;==================================================
;=== HEAD NEWS FEED READER (Side Lines) ===========
;==================================================

[HEADLINES]
Meter=SHAPE
X=0
Y=20
Shape=Rectangle 0,0,8,8 | Extend ModifiersS1
Shape2=Line 8,4,26,4 | Extend ModifiersL1
Shape3=Rectangle 26,0,8,8 | Extend ModifiersS1
;-----
Shape4=Rectangle 0,16,8,8 | Extend ModifiersS2
Shape5=Line 8,20,26,20 | Extend ModifiersL2
Shape6=Rectangle 26,16,8,8 | Extend ModifiersS2
;-----
Shape7=Rectangle ([HEADNAME:W] + 48),0,8,8 | Extend ModifiersS1
Shape8=Rectangle ([HEADNAME:W] + 48),0,8,8 | Extend ModifiersS1
Shape9=Rectangle ([HEADNAME:W] + 48),16,8,8 | Extend ModifiersS2
Shape10=Rectangle ([HEADNAME:W] + 48),16,8,8 | Extend ModifiersS2
;-----
Shape11=Rectangle 872,0,8,8 | Extend ModifiersS1
Shape12=Line 854,4,872,4 | Extend ModifiersL1
Shape13=Rectangle 846,0,8,8 | Extend ModifiersS1
;-----
Shape14=Rectangle 872,16,8,8 | Extend ModifiersS2
Shape15=Line 854,20,872,20 | Extend ModifiersL2
Shape16=Rectangle 846,16,8,8 | Extend ModifiersS2
ModifiersS1=StrokeWidth 0 | Fill Color #Color3##Alpha2#
ModifiersL1=StrokeWidth 2 | StrokeColor #Color3##Alpha2#
ModifiersS2=StrokeWidth 0 | Fill Color #Color3##Alpha1#
ModifiersL2=StrokeWidth 2 | StrokeColor #Color3##Alpha1#
DynamicVariables=1
UpdateDivider=-1
Group=FEED

[HEADNAME]
Meter=STRING
MeterStyle=StHEAD
X=41
Y=r
MouseOverAction=[!SetOption HEADNAME FontColor "#Color4##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]
MouseLeaveAction=[!SetOption HEADNAME FontColor "#Color3##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]
LeftMouseUpAction=[#vURL#]

;==================================================
;=== MARQUEE NEWS FEED READER =====================
;==================================================

;=== CONTAINER NEWS FEED ==========================

[CONTAINER_NFR]
Meter=SHAPE
X=0
Y=r
Shape=Line ([HEADNAME:W] + 63),0,839,0 | StrokeWidth 47 | StrokeColor #Color0##Alpha1#
DynamicVariables=1
UpdateDivider=-1
LeftMouseDoubleClickAction=[#vURL#]
Group=FEED

;=== MARQUEE NEWS FEED ============================

[NewsFeed]
Meter=STRING
MeterStyle=StNEWS
X=[mXPos]r
Y=r
2.) newsfeeddata.inc

Code: Select all

[Variables]
;********************************************************************************************************************************************************
;********************************************************************************************************************************************************
;***                                                                                                                                               ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;*** !!!!!!!!!!!!!!!!!!   DON`T CHANGE ANYTHING IN THIS FILE   !!!!!!!!!!!!!!!!!!!!!!!   Unless you know what you are doing :-) !!!!!!!!!!!!!!!!!! ******
;***                                                                                                                                               ******
;********************************************************************************************************************************************************
;********************************************************************************************************************************************************
;==================================================
;=== VARIABLES FONTFACE - SIZE - COLORS ===========
;==================================================
FontFace=SQUARE721 BT
FS1=10
FS2=8
Alpha0=1
Alpha1=255
Alpha2=70
Color0=0,0,0,
Color1=160,246,253,
Color2=48,180,200,
Color3=97,240,255,
Color4=253,193,0,
Color5=255,255,255
Color6=255,104,67,
;==================================================
;=== VARIABLES SPEECH PLUGIN (NewsFeed) ===========
;==================================================
VoiceName=Microsoft Hedda Desktop
;IndexName= 
;VoiceGender=
DebugModus=0
VoiceVolume=100
SpeedRate=-2
NewsUpdSpeech=News Feed aktualisiert
;==================================================
;=== VARIABLES NEWS FEED READER ===================
;==================================================
Direction=-1
StartPos=850
RSSUrl=https://news.google.com/rss?pz=1&cf=all&hl=de&gl=DE&ceid=DE:de
vURL=http://news.google.de/
NF1=.*<item.*<title.*>(.*)</title>.*
NF2=.*<title.*>(.*)</title>
NF3=.*<title.*>(.*)</title>
NF4=.*<title.*>(.*)</title>
NF5=.*<title.*>(.*)</title>
TSL=de-DE
FL=de-DE
;==================================================
;=== STYLE NEWS FEED HEAD (Side Line) =============
;==================================================

[StLAYER]
Padding=0,-3,-1,-3
SolidColor=#Color0##Alpha0#
FontColor=#Color1##Alpha1#
FontFace=#FontFace#
FontSize=#FS2#
StringCase=UPPER
AntiAlias=1
Text=LAYER NFR   POS: [NewsFeed:Y] [\x00B7] [mXPos]
InlineSetting=Color | #Color6##Alpha1#
InlinePattern=[NewsFeed:Y]
InlineSetting2=Color | #Color4##Alpha1#
InlinePattern2=[\x00B7](.*)
DynamicVariables=1
UpdateDivider=1
Group=FEED

[StNFRUPDATE]
Padding=0,-3,-1,-3
SolidColor=#Color0##Alpha0#
FontColor=#Color1##Alpha1#
FontFace=#FontFace#
FontSize=#FS2#
StringCase=UPPER
AntiAlias=1
Text=LAST NFR-UPD: [mNFRUT] [\x2022] LAST NFP-BUILD: [mLBTSF]
InlineSetting=Color | #Color6##Alpha1#
InlinePattern=[mNFRUT] | [mLBTSF]
DynamicVariables=1
UpdateDivider=-1
Group=FEED

[StHEAD]
Padding=0,4,-1,5
SolidColor=#Color0##Alpha0#
FontColor=#Color3##Alpha1#
FontFace=#FontFace#
FontSize=#FS1#
StringCase=UPPER
AntiAlias=1
Text=[mRSSNPN]
ClipString=2
ClipStringW=105
ClipStringH=15
DynamicVariables=1
UpdateDivider=-1
Hidden=1

;==================================================
;=== STLYE NEWS FEED ==============================
;==================================================

[StNEWS]
Padding=0,4,-1,5
SolidColor=#Color0##Alpha0#
FontColor=#Color5##Alpha1#
FontFace=#FontFace#
FontSize=#FS1#
StringCase=UPPER
AntiAlias=1
Text=[\x2022][\x2022][\x2022]  [mRSSItem1]  [\x2022][\x2022][\x2022]  [mRSSItem2]  [\x2022][\x2022][\x2022]  [mRSSItem3]  [\x2022][\x2022][\x2022]  [mRSSItem4]  [\x2022][\x2022][\x2022]  [mRSSItem5]  [\x2022][\x2022][\x2022] 
InlineSetting=Color | #Color1##Alpha1#
InlinePattern=(?i)[mRSSItem1] | (?i)[mRSSItem3] | (?i)[mRSSItem5]
InlineSetting2=Color | #Color2##Alpha1#
InlinePattern2=(?i)[mRSSItem2] | (?i)[mRSSItem4]
DynamicVariables=1
UpdateDivider=1
Hidden=1
Container=CONTAINER_NFR
Group=FEED
Unfortunately I can't get this code to work. The WebParser measures don't return anything, but get a RegExp matching error (-1) message in the log. Please check the code, something is not alright with it.