您的位置:程序门 -> vb -> 基础类



vb 程序获取天气预报数据是如何实现的。


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vb 程序获取天气预报数据是如何实现的。
发表于:2008-01-21 11:07:56 楼主
vb   程序获取天气预报数据是如何实现的。有源码吗?
发表于:2008-01-21 11:43:231楼 得分:0
路过,关注..
发表于:2008-01-22 22:20:542楼 得分:0
首先找一个更新及时的网页,比如waether.qq.com
然后把网页下载回来,或者其它方法读取源码,分析提取天气信息,再显示
发表于:2008-01-22 22:57:203楼 得分:0
难点是找数据,只要有数据一切就简单了。
发表于:2008-01-23 09:16:084楼 得分:0
好像有类似的例子,在网上能找得到
发表于:2008-01-23 15:10:455楼 得分:0
//执行
private   sub   command1_click()
        if   combo2.text   =   ""   then
                msgbox   "请选择城市!",   vbokonly   +   64,   "提示"
        else
                strhtml   =   ""
                tital.caption   =   combo2.text   &   "天气"
                staflag   =   0
                call   webbrowser1.navigate("http://php.weather.sina.com.cn/search.php?city="   &   combo2.text)
                label1.caption   =   "请   稍   后   ..."
        end   if
end   sub
//处理数据
private   sub   webbrowser1_downloadcomplete()
        dim   i   as   long
        dim   j   as   long
        dim   k   as   long
        dim   inttemp   as   integer
        on   error   resume   next
        if   len(strhtml)   =   0   then
                'get   data
                strhtml   =   webbrowser1.document.documentelement.innerhtml
                if   len(strhtml)   <>   0   then
                        for   j   =   0   to   2
                                i   =   instr(strhtml,   " <div   class=city_data> ")
                                strhtml   =   mid$(strhtml,   i)
                                weatherday(j).stradd   =   getdata(" <h3> ",   " </h3> ",   strhtml)
                                weatherday(j).strdate   =   getdata(" <p> ",   " </p> ",   strhtml)
                                weatherday(j).strpicpath   =   getdata("src="   &   chr$(34),   chr$(34)   &   "> </div> ",   strhtml)
                                weatherday(j).strweather   =   getdata("weather_tp> ",   " </div> ",   strhtml)
                                weatherday(j).strwind   =   getdata("weather_w> ",   " </div> ",   strhtml)
                                i   =   instr(strhtml,   " <div   class=weather_sm")
                                strhtml   =   mid$(strhtml,   i)
                                inttemp   =   iif(j   =   0,   9,   5)
                                for   k   =   0   to   inttemp
                                        weatherday(j).strsm(k)   =   getdata(" <p> ",   " </p> ",   strhtml)
                                next
                        next
                        'display   data
                        call   displaydata(staflag)
                 
                        label1.caption   =   "下载完成   "
                end   if

        end   if
exit   sub
err1:

end   sub
发表于:2008-01-23 18:44:146楼 得分:0
要根据天气页面的情况分析以确定提取的方法。
发表于:2008-01-23 19:09:367楼 得分:0
看看这篇文章吧,是asp代码,不过和vb实现是一样的。
http://lh80.blog.sohu.com/63383113.html
发表于:2008-01-23 20:19:418楼 得分:0
可以调用网上提供天气预报的web   services来实现
如果对这个有兴趣,可以在论坛上输入天气预报搜索一下,记得前不久回过这样的帖子


快速检索

最新资讯
热门点击