It is currently April 20th, 2024, 4:58 am

webparser issues

Get help with creating, editing & fixing problems with skins
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

webparser issues

Post by Ragingwasabi »

Hi,
I have problems with webparser where log says:
regexp matching error (-1)


RSS feed of interest:
http://feeds.bbci.co.uk/news/world/rss.xml


is it something to do with the square parantheses [ ] in the regexp?
this regexp used to work but it seems BBC recently changed their xml feed structure by adding the [CDATA[ ]] thingy. So i tried to fix it, but its not working.


My code (stripped down):

Code: Select all


[Variables]
; BBCitemsect contains the regular expression for parsing 1 section/headline. multiple of instances of this variable are used to obtain all headlines from the RSS feed. see [RSS] section below
; (?=.*<item>) look ahead assertions used because not always >=24 items in RSS feed.
BBCitemsect=(?(?=.*<item>)<item>.*<title><![CDATA[(.*)]]></title>.*<description><![CDATA[(.*)]]></description>.*<link>(.*)</link>.*<pubDate>(.*)</pubDate>.*</item>.*)	



[RSS]
Measure=Plugin
Plugin=WebParser
Url=http://feeds.bbci.co.uk/news/world/rss.xml
RegExp=(?siU)#BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect##BBCitemsect#
UpdateRate=300



;------

[RSS1title]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =1
Substitute = #Substitute#

[RSS1descript]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =2
Substitute = #Substitute#

[RSS1link]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =3
Substitute = #Substitute#

[RSS1date]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =4
Substitute = #Substitute#

;------

[RSS2title]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =5
Substitute = #Substitute#

[RSS2descript]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =6
Substitute = #Substitute#

[RSS2link]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =7
Substitute = #Substitute#

[RSS2date]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =8
Substitute = #Substitute#

;------

[RSS3title]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =9
Substitute = #Substitute#

[RSS3descript]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =10
Substitute = #Substitute#

[RSS3link]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =11
Substitute = #Substitute#

[RSS3date]
Measure = Plugin
Plugin=WebParser
Url = [RSS]
StringIndex =12
Substitute = #Substitute#


[RSS1linkbutton]
meter = image
x = 0
y = 28r
h = #clickhovbarH#
w = #seplinwidth#
solidcolor =0,0,0,1
mouseoveraction = [!SetOption #CURRENTSECTION# solidcolor #hoverbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]
mouseleaveaction = [!SetOption #CURRENTSECTION# solidcolor 0,0,0,1][!Updatemeter #CURRENTSECTION# ][!Redraw]
leftmousedownaction = [!SetOption #CURRENTSECTION# solidcolor #clickbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]
leftmouseupaction = [!SetOption #CURRENTSECTION# solidcolor #hoverbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]["#eVIEWER#"  "[RSS1link]]"
hidden=0



[RSS1String]
Meter = STRING
MeasureName = RSS1title
X = 15
Y = #relbartext#
FontColor = #txtcolor#
FontSize = #txtsize#
FontFace = #txtfont#
StringEffect = #txteffect#
FontEffectColor = #txteffectcolor#
AntiAlias = 0
Prefix = #dotpt#
ClipString = #CPS#
ClipStringW = #CPSW#
ClipStringH = #CPSH#
hidden=0


;------


[RSS2linkbutton]
meter = image
x = 0
y = 28r
h = #clickhovbarH#
w = #seplinwidth#
solidcolor =0,0,0,1
mouseoveraction = [!SetOption #CURRENTSECTION# solidcolor #hoverbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]
mouseleaveaction = [!SetOption #CURRENTSECTION# solidcolor 0,0,0,1][!Updatemeter #CURRENTSECTION# ][!Redraw]
leftmousedownaction = [!SetOption #CURRENTSECTION# solidcolor #clickbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]
leftmouseupaction = [!SetOption #CURRENTSECTION# solidcolor #hoverbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]["#eVIEWER#"  "[RSS2link]]"
hidden=0


[RSS2String]
Meter = STRING
MeasureName = RSS2title
X = 15
Y = #relbartext#
FontColor = #txtcolor#
FontSize = #txtsize#
FontFace = #txtfont#
StringEffect = #txteffect#
FontEffectColor = #txteffectcolor#
AntiAlias = 0
Prefix = #dotpt#
ClipString = #CPS#
ClipStringW = #CPSW#
ClipStringH = #CPSH#
hidden=0

;------


[RSS3linkbutton]
meter = image
x = 0
y = 28r
h = #clickhovbarH#
w = #seplinwidth#
solidcolor =0,0,0,1
mouseoveraction = [!SetOption #CURRENTSECTION# solidcolor #hoverbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]
mouseleaveaction = [!SetOption #CURRENTSECTION# solidcolor 0,0,0,1][!Updatemeter #CURRENTSECTION# ][!Redraw]
leftmousedownaction = [!SetOption #CURRENTSECTION# solidcolor #clickbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]
leftmouseupaction = [!SetOption #CURRENTSECTION# solidcolor #hoverbarcolor#][!Updatemeter #CURRENTSECTION#][!Redraw]["#eVIEWER#"  "[RSS3link]]"
hidden=0


[RSS3String]
Meter = STRING
MeasureName = RSS3title
X = 15
Y = #relbartext#
FontColor = #txtcolor#
FontSize = #txtsize#
FontFace = #txtfont#
StringEffect = #txteffect#
FontEffectColor = #txteffectcolor#
AntiAlias = 0
Prefix = #dotpt#
ClipString = #CPS#
ClipStringW = #CPSW#
ClipStringH = #CPSH#

User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: webparser issues

Post by FreeRaider »

Try this:

Code: Select all

(?siU)(?(?=.*<item>).*<item>.*<title><!\[CDATA\[(.*)\]\]></title>.*<description><!\[CDATA\[(.*)\]\]></description>.*<link>(.*)</link>.*<pubDate>(.*)</pubDate>.*</item>.*)
:welcome:
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

Re: webparser issues

Post by Ragingwasabi »

FreeRaider wrote:Try this:

Code: Select all

(?siU)(?(?=.*<item>).*<item>.*<title><!\[CDATA\[(.*)\]\]></title>.*<description><!\[CDATA\[(.*)\]\]></description>.*<link>(.*)</link>.*<pubDate>(.*)</pubDate>.*</item>.*)
:welcome:
It works!!! thanks so much ^^

so i guess the back slash is an escape character, and the square brackets are reserved for some other funky business :p
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: webparser issues

Post by jsmorley »

Ragingwasabi wrote:It works!!! thanks so much ^^

so i guess the back slash is an escape character, and the square brackets are reserved for some other funky business :p
Correct.

Reserved characters in regular expression, which are . ^ $ * + ? ( ) [ { \ | must be escaped with the \ character when used as a literal.
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

Re: webparser issues

Post by Ragingwasabi »

gawd seems so easy to fix now lol. i thought my regexp syntax was the issue for hours
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: webparser issues

Post by jsmorley »

Ragingwasabi wrote:gawd seems so easy to fix now lol. i thought my regexp syntax was the issue for hours
All problems were easy after you fix them... ;-)
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: webparser issues

Post by balala »

FreeRaider wrote:Try this:

Code: Select all

(?siU)(?(?=.*<item>).*<item>.*<title><!\[CDATA\[(.*)\]\]></title>.*<description><!\[CDATA\[(.*)\]\]></description>.*<link>(.*)</link>.*<pubDate>(.*)</pubDate>.*</item>.*)
In my opinion the following would be in fact the right expression:

Code: Select all

(?siU)(?(?=.*<item>).*<item>.*<title><!\[CDATA\[(.*)]]></title>.*<description><!\[CDATA\[(.*)]]></description>.*<link>(.*)</link>.*<pubDate>(.*)</pubDate>.*</item>.*)
That's because [ is a reserved character, but ] isn't.
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

Re: webparser issues

Post by Ragingwasabi »

hmm interesting, ur right, i didnt notice before but Jsmorley didnt include ] in the list he gave