Rainmeter 天气

http://tieba.baidu.com/p/5816309617来自百度的天气数据抓取

http://tieba.baidu.com/p/4830073469?pn=1Clock and weather  

主要是看了这两篇帖子第一个是方法来源,第二个是样式来源。

本来是用百度搜索当地天气读取,后来改为读取墨迹天气页面比如  https://tianqi.moji.com/weather/china/fujian/xiamen 为厦门市天气的页面。

如图所示,显示的图标和温度都是直接抓取网页上的。

用WebParser来抓取,具体方法第一个帖子写得很清楚了,贴一下我的代码。

具体用起来有个缺点,一个是设置为每15分钟下载一次网页源码,但是下一次15分钟后才会更新到显示(我也不知道为什么),所以刚开机时并不会正常显示,过半小时就正常了(这个具体我没有认真测,反正就是存在一定的延时,实在想快一点正常显示就rainmeter刷新两下就好了)。然后为了刷新网页缓存,翻了翻手册写了   Header=Cache-Control: no-cache  这一行代码进去,不知道有没有效,反正勉强能用就是了。

;更新系数
[Rainmeter]
Update=1500
DynamicWindowSize=1

;脚本信息
[Metadata]
Name=天气·墨迹网页
Author=EG
Version=0.1
License=Personal


;变量
[Variables]

;==============网页========================
;网页处理
[DownloadWeather]
Measure=Plugin
Plugin=WebParser
Header=Cache-Control: no-cache
Url=https://tianqi.moji.com/weather/china/fujian/siming-district
Download=1
DownloadFile=moji.html


[Weather]
Measure=Plugin
Plugin=WebParser
UpdateDivider=1
Url=file://%userprofile%\Documents\Rainmeter\Skins\illustro\Weather\DownloadFile\moji.html
RegExp=(?siU)<div class="wea_weather clearfix">.*<em>(.*)em>.*<img src="(.*)" alt.*<b>(.*)</b>.*<div class="wea_tips clearfix">.*<em>(.*)</em>.*<div class="forecast clearfix">.*明天</a>.*<img src="(.*)" alt.*<li>(.*) / (.*)</li>.*后天</a>.*<img src="(.*)" alt.*<li>(.*) / (.*)</li>

;现在气温
[WeatherToday]
Measure=WebParser
Url=[Weather]
StringIndex=1
DefaultValue=无
Substitute="</":"°"

;现在天气图标
[MeasureWeathericon]
Measure=WebParser
Url=[Weather]
StringIndex=2
Download=1
DownloadFile=1.png

;今日天气描述
[MeasureTodayWeather]
Measure=WebParser
Url=[Weather]
StringIndex=3
DefaultValue=无


;今日天气提示
[MeasureTodaySuggestion]
Measure=WebParser
Url=[Weather]
StringIndex=4
DefaultValue=无

;---明天


;天气图标
[MeasureToWeathericon]
Measure=WebParser
Url=[Weather]
StringIndex=5
Download=1
DownloadFile=2.png


;气温1
[WeatherTom1]
Measure=WebParser
Url=[Weather]
StringIndex=7
DefaultValue=无


;气温2
[WeatherTom2]
Measure=WebParser
Url=[Weather]
StringIndex=6
DefaultValue=无


;---后天


;图标
[MeasureAftWeathericon]
Measure=WebParser
Url=[Weather]
StringIndex=8
Download=1
DownloadFile=3.png

;气温1
[WeatherAft1]
Measure=WebParser
Url=[Weather]
StringIndex=10
DefaultValue=无


;气温2
[WeatherAft2]
Measure=WebParser
Url=[Weather]
StringIndex=9
DefaultValue=无

;===================天气显示============



;今日气温
[MeterTodayTemp]
Meter=String
DynamicVariables=1
MeasureName=WeatherToday
DefaultValue=无
FontColor=255,255,255
FontSize=20
AntiAlias=1
FontFace=Comic Sans MS
X=10
Y=10


;现在天气图标
[MeterIcon]
DynamicVariables=1
MeasureName=MeasureWeathericon
Meter=image
X=50
Y=40
H =80


;明日天气描述图标
[MeterFutureIcon]
DynamicVariables=1
MeasureName=MeasureToWeathericon
Meter=image
X=200
Y=40
H = 50




;明日气温1
[MeterFutureTemp1]
Meter=String
DynamicVariables=1
MeasureName=WeatherTom1
FontColor=255,255,255
FontSize=14
AntiAlias=1
FontFace=Comic Sans MS
X=240
Y=87


;明日气温2
[MeterFutureTemp2]
Meter=String
DynamicVariables=1
MeasureName=WeatherTom2
FontColor=255,255,255
FontSize=16
AntiAlias=1
FontFace=Comic Sans MS
X=180
Y=10
W = 90




;后日天气描述图标
[MeterAfterFutureIcon]
DynamicVariables=1
MeasureName=MeasureAftWeathericon
Meter=image
X=340
Y=40
H = 50



;后日气温1
[MeterAfterFutureTemp1]
Meter=String
DynamicVariables=1
MeasureName=WeatherAft1
FontColor=255,255,255
FontSize=14
AntiAlias=1
FontFace=Comic Sans MS
X=380
Y=87
W = 50

;后日气温2
[MeterAfterFutureTemp2]
Meter=String
DynamicVariables=1
MeasureName=WeatherAft2
FontColor=255,255,255
FontSize=16
AntiAlias=1
FontFace=Comic Sans MS
X=320
Y=10
W = 90

  

猜你喜欢

转载自www.cnblogs.com/OoYol/p/11042764.html
今日推荐