asia 发表于 2011-3-13 02:52:01

解决国内天气预报更新出现的问题

这几天看到大家不断的提出天气预报出现的错误,看来这个问题还真不小。原因是天气网“http://www.weather.com.cn/data/sk/某地代码.html”对源码的更改
现在的:
{"weatherinfo":{"city":"番禺","cityid":"101280102","temp":"15","WD":"西北风","WS":"2级","SD":"91%","WSE":"2","time":"01:50","isRadar":"0","Radar":""}}
其中,temp=当天温度,WD=风向   ,WS=风速,SD=湿度   ,WSE=?? ,time=发布时间


对应原来的天气源码的正则表达式是:
RegExp={"weatherinfo":{"city":"(.*)","cityid":"(.*)","temp":"(.*)","WD":"(.*)","WS":"(.*)","SD":"(.*)","AP":"(.*)","njd":"(.*)","WSE":"(.*)","time":"(.*)","sm":"(.*)","isRadar":"(.*)","Radar":"(.*)"}}


现在的天气源码的正则表达式是:
RegExp={"weatherinfo":{"city":"(.*)","cityid":"(.*)","temp":"(.*)","WD":"(.*)","WS":"(.*)","SD":"(.*)","WSE":"(.*)","time":"(.*)","isRadar":"(.*)","Radar":"(.*)"}}


大家可以发现,从红色的地方,表达式发生的变化。原来天气发布时间"time":"(.*)",的位置10现在到了8
/*********************************************************************************
两个主要Measure,直接从网页上获取所需的天气信息
            ;当天和未来几天的天气信息
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=600
Url=http://m.weather.com.cn/data/#CODE#.html
RegExp="{"weatherinfo":{"city":"(.*)","city_en":"(.*)","date_y":"(.*)","date":"(.*)","week":"(.*)","fchh":"(.*)","cityid":"(.*)","temp1":"(.*)","temp2":"(.*)","temp3":"(.*)","temp4":"(.*)","temp5":"(.*)","tempF1":"(.*)","tempF2":"(.*)","tempF3":"(.*)","tempF4":"(.*),"tempF5":"(.*)","weather1":"(.*)","weather2":"(.*)","weather3":"(.*)","weather4":"(.*)","weather5":"(.*)","img1":"(.*)","img2":"(.*)","img3":"(.*)","img4":"(.*)","img5":"(.*)","img6":"(.*)","img7":"(.*)","img8":"(.*)","img9":"(.*)","img10":"(.*)","img_single":"(.*)","img_title1":"(.*)","img_title2":"(.*)","img_title3":"(.*)","img_title4":"(.*)","img_title5":"(.*)","img_title6":"(.*)","img_title7":"(.*)","img_title8":"(.*)","img_title9":"(.*)","img_title10":"(.*)","img_title_single":"(.*)","wind1":"(.*)","wind2":"(.*)","wind3":"(.*)","wind4":"(.*)","wind5":"(.*)","fl1":"(.*)","fl2":"(.*)","fl3":"(.*)","fl4":"(.*)","fl5":"(.*)","index":"(.*)","index_d":"(.*)","index48":"(.*)","index48_d":"(.*)","index_uv":"(.*)","index48_uv":"(.*)","index_xc":"(.*)","index_tr":"(.*)","index_co":"(.*)","st1":"(.*)","st2":"(.*)","st3":"(.*)","st4":"(.*)","st5":"(.*)","st6":"(.*)"}}"
StringIndex=1


;---------------WeatherNOW----------------------


   ;当天的详细天气信息
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=100
Url=http://www.weather.com.cn/data/sk/#CODE#.html
RegExp={"weatherinfo":{"city":"(.*)","cityid":"(.*)","temp":"(.*)","WD":"(.*)","WS":"(.*)","SD":"(.*)","WSE":"(.*)","time":"(.*)","isRadar":"(.*)","Radar":"(.*)"}}
StringIndex=1
/**************************************************************************************************************************/

下面是获取天气发布时间的代码:
获取天气发布时间

Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=
StringIndex=8;原来是=10,stringindex的值就是第几个(.*),天气发布时间是time后面的(.*)

;同理,获取城市名的stringIndex=1

Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=
StringIndex=1



;当天温度

Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=
StringIndex=3



;当天湿度

Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=
StringIndex=6

风速(WS)对应的StringIndex=5,
风向(WD)对应的StringIndex=4,

用记事本的搜索功能找到对应的Measure改过来就可以了。注意,这些Measure下面的URL都是=,
现在的天气没有的气压(AP)等项

现在就想到这些问题,如果还有其它的问题再提出来吧

a5164791 发表于 2011-3-13 07:15:35

多谢楼主。我的天气又完好可用了。

本家 发表于 2011-3-13 10:04:31

受教了…………

毛毛 发表于 2011-3-13 17:57:45

完全没明白,后来改的字都挤一起了。。。

潇湘竹女 发表于 2011-3-14 18:38:33

回帖留作记号,,,问题解决了,感谢楼主

zhuzhuo2510 发表于 2011-3-15 22:55:00

不行啊 乱套了

冷辞 发表于 2011-3-18 22:05:07

谢谢哈。。。又ok了

dannylin 发表于 2011-3-21 09:21:08

正在头痛这个问题,看了LZ的解答,帮助太大了。谢谢!
顺手把自己改好的ini发一份上来。(TOKEN的套装天气)

thzej 发表于 2011-3-23 22:44:44

十分
感谢

thzej 发表于 2011-3-23 22:45:07

十分
感谢@@wohaoku
页: [1] 2 3 4 5 6 7 8
查看完整版本: 解决国内天气预报更新出现的问题