無法顯示天氣
剛安裝好這個桌面插件的時候, 我畫紅線的這個部分是無法顯示天氣數值的,我就在網上找了別人的代碼來參考,
這是參考的博客:https://blog.csdn.net/Hugo_1st/article/details/106084414
[Variables] @include=#@#Variables.inc @include2=#@#Language\Language.inc @Include3=#@#WXDataWeatherRegExp.inc Scale=0.35 Location=https://tianqi.moji.com/weather/china/guangxi/lingchuan-county 這里放上你所在地區的URL ;------------------------------------------------------------- ;------------------------------------------------------------- [WeatherParent] Measure=Plugin Plugin=WebParser.dll URL=#Location# RegExp="(?siU)<div class="wea_weather clearfix">.*<em>(.*)</em>" StringIndex=1 UpdateRate=900 ForceReload=1 FinishAction=[!EnableMeasureGroup Weather][!UpdateMeter *][!Redraw]
這是我更改過后的代碼,原來的代碼為:
[Variables] @include=#@#Variables.inc @include2=#@#Language\Language.inc @Include3=#@#WXDataWeatherRegExp.inc Scale=0.35;------------------------------------------------------------- ;------------------------------------------------------------- [WeatherParent] Measure=Plugin Plugin=WebParser URL=#某個URL# RegExp=(?siU)^(.*)$ UpdateRate=900 ForceReload=1 FinishAction=[!EnableMeasureGroup Weather][!UpdateMeter *][!Redraw]
參考的博客的博主使用的是墨跡天氣的數據,通過RegExp匹配HTML的元素。
而我更改后還沒搞定,還沒顯示天氣,我認為是他之后的元素不斷的引用傳遞時出現錯誤
[CurrentConditionsParent] Measure=Plugin Group=Weather Plugin=WebParser URL=[WeatherParent] RegExp=#CurrentConditions# Disabled=1 [CurrentTempChild] Measure=Plugin Group=Weather Plugin=WebParser URL=[CurrentConditionsParent] StringIndex=3 Disabled=1 [UnitsParent] Measure=Plugin Group=Weather Plugin=WebParser URL=[WeatherParent] RegExp=#UnitsOfMeasure# Disabled=1 [UnitsTempChild] Measure=Plugin Group=Weather Plugin=WebParser URL=[UnitsParent] StringIndex=3 Disabled=1
這些都是不斷的引用第一段所獲取到的數據,所以我決定直接在顯示數據的變量調用第一段的數據,不調用引用之后的數據
[MeterInfo] Meter=String MeasureName=MeasureDate MeasureName2=MeasureDate2 MeasureName3=MeasureMonth MeasureName4=MeasureDayOfYear MeasureName5=CurrentConditionsChild MeasureName6=WeatherParent 更改了這里,直接調用第一段數據 MeasureName7=UnitsTempChild MeasureName8=MeasureCPU MeasureName9=MeasurePhysMemUsed StringAlign=Center FontFace=Quicksand Light FontColor=#Color1# FontSize=(35*#Scale#) X=(0*#Scale#)r Y=(200*#Scale#) Text="#Welcome back again#. #Today is# %1%2 %3, %4 #day of the year#.#CRLF##Weather today is# %5 #with temperature# %6 °%7.#CRLF##Cpu usage is# %8%. #Ram usage is# %9%." InlinePattern=[MeasureMonth] InlineSetting=Color | #Color2# InlinePattern2=[CurrentConditionsChild] InlineSetting2=Color | #Color2# DynamicVariables=1 AntiAlias=1 Percentual=1 Hidden=#Hidden#
在更改完這部分之后,刷新皮膚就能看見所在地區的天氣氣溫了