我试图为Rainmeter做一个皮肤,显示用户个人资料页面中的信誉得分和徽章数量。如果用户每个类别(金,银,铜)至少有一个徽章,那么一切都很有效,但就我而言,我还没有任何金徽章,皮肤看起来像{{0} }。所需的输出将类似Stack Overflow 401 0 1 7.我的实际代码如下。
[Rainmeter]
Author=Dragos Sandu
Update=1000
DynamicWindowSize=1
[Metadata]
Name=Stack Overflow Stats
Author=Dragos Sandu
Version=28 March 2015 rev 1
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Simple stats displaying for Stack Overflow
[Variables]
FontName=Trebuchet MS
FontSize=12
[MeasureAll]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=http://stackoverflow.com/users/2691507/dragos-sandu
RegExp=(?siU)<span class="reputation-score">(.*)</span>.*<span class="badgecount">(.*)</span>.*<span class="badgecount">(.*)</span>.*<span class="badgecount">(.*)</span>
[MeasureReputation]
Measure=Plugin
Plugin=WebParser
URL=[MeasureAll]
StringIndex=1
[MeasureGold]
Measure=Plugin
Plugin=WebParser
URL=[MeasureAll]
StringIndex=2
[MeasureSilver]
Measure=Plugin
Plugin=WebParser
URL=[MeasureAll]
StringIndex=3
[MeasureBronze]
Measure=Plugin
Plugin=WebParser
URL=[MeasureAll]
StringIndex=4
[MeterText]
Meter=String
Prefix="Stack Overflow "
FontFace=#FontName#
FontColor=#FFF
FontSize=#FontSize#
StringAlign=Left
[MeterReputation]
Meter=String
MeasureName=MeasureReputation
FontFace=#FontName#
FontColor=F0F0F0
FontSize=#FontSize#
StringAlign=Left
StringStyle=bold
X=120
[MeterGold]
Meter=String
MeasureName=MeasureGold
X=195
FontFace=#FontName#
FontColor=FFCC00
FontSize=#FontSize#
StringStyle=bold
StringAlign=Left
[MeterSilver]
Meter=String
MeasureName=MeasureSilver
X=235
FontFace=#FontName#
FontColor=C5C5C5
FontSize=#FontSize#
StringStyle=bold
StringAlign=Left
[MeterBronze]
Meter=String
MeasureName=MeasureBronze
X=285
FontFace=#FontName#
FontColor=CC9966
FontSize=#FontSize#
StringStyle=bold
StringAlign=Left
我阅读了一些关于Webparser Lookahead Assertions的内容并尝试使用RegExp,但没有成功。我得到的最好结果是(?siU)<span class="reputation-score">(.*)</span>(?(?=.*<span title="(.*) gold))(?(?=.*<span title="(.*) silver))(?(?=.*<span title="(.*) bronze))
,但它并没有提供我想要的东西。什么应该是正确的RegExp?谢谢!
答案 0 :(得分:0)
我放弃了这个小项目,但今天我终于成功了。 Stackoverflow最近改变了他的外观,他的类和HTML也是如此。所以,现在我能够使用Rainmeter docs中的Lookahead Assertions方法解析欲望信息。对于感兴趣的每个人,我将在下面发布我的工作RegExp。此外,很快就会提供整个Rainmeter Skin的链接。
RegExp=(?siU)<div class="reputation" title="reputation">(.*)<span.*(?(?=.*class="badge1-alternate").*<span class="badge1"></span><span class="badgecount">(.*)</span></span>).*(?(?=.*class="badge2-alternate").*<span class="badge2"></span><span class="badgecount">(.*)</span></span>).*(?(?=.*class="badge3-alternate").*<span class="badge3"></span><span class="badgecount">(.*)</span></span>)