我正在尝试为 Rainmeter 做一个皮肤,它显示来自用户个人资料页面的声誉分数和徽章数量。如果用户在每个类别(金、银、铜)中至少有一个徽章,一切都会很好,但以我为例,我还没有任何金徽章,皮肤看起来像. 所需的输出将类似于 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))
但它没有提供我想要的。什么应该是正确的正则表达式?谢谢!