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

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM