| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 930 人关注过本帖
标题:问什么下面这个天气抓取程序不能运行呢?
取消只看楼主 加入收藏
郁郁界河
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2013-10-14
收藏
 问题点数:0 回复次数:6 
问什么下面这个天气抓取程序不能运行呢?
程序代码:
PUBLIC goForm
goForm = CREATEOBJECT("ShowWeather")
goForm.Show()


DEFINE CLASS ShowWeather AS Form

    Caption = "Weather Report[Hong Kong]"
    Width = 400
    Height = 340
    MaxButton = .F.
   
    ADD OBJECT Command1 AS CommandButton WITH ;
        Left = 300, ;
        Top = 290, ;
        Width = 80, ;
        Height = 27, ;
        Caption = "\<Refresh"
   
    PROCEDURE Init
        PRIVATE i, loObject
        LOCAL i, loObject
        FOR i = 1 TO 8
            THIS.AddObject("Image" + ALLTRIM(STR(i)), "Image")
            loObject = EVALUATE("THIS.Image" + ALLTRIM(STR(i)))
            WITH loObject
                .Left = 90*(IIF(i <= 4, i, i - 4) - 1) + 30
                .Top = IIF(i <= 4, 30, 160)
                .Width = 64
                .Height = 64
                .Stretch = 1
                .Visible = .T.
            ENDWITH
            THIS.AddObject("Label" + ALLTRIM(STR(i)) + "1", "Label")
            loObject = EVALUATE("THIS.Label" + ALLTRIM(STR(i)) + "1")
            WITH loObject
                .Left = 90*(IIF(i <= 4, i, i - 4) - 1) + 30
                .Top = IIF(i <= 4, 100, 230)
                .BackStyle = 0
                .Width = 64
                .Height = 18
                .Alignment = 2
                .ForeColor = IIF(i = 1, RGB(255, 0, 0), RGB(0, 0, 0))
                .FontBold = IIF(i = 1, .T., .F.)
                .Visible = .T.
            ENDWITH
            THIS.AddObject("Label" + ALLTRIM(STR(i)) + "2", "Label")
            loObject = EVALUATE("THIS.Label" + ALLTRIM(STR(i)) + "2")
            WITH loObject
                .Left = 90*(IIF(i <= 4, i, i - 4) - 1) + 30
                .Top = IIF(i <= 4, 115, 245)
                .BackStyle = 0
                .Width = 64
                .Height = 18
                .Alignment = 2
                .ForeColor = IIF(i = 1, RGB(255, 0, 0), RGB(0, 0, 0))
                .FontBold = IIF(i = 1, .T., .F.)
                .Visible = .T.
            ENDWITH
            THIS.AddObject("Label" + ALLTRIM(STR(i)) + "3", "Label")
            loObject = EVALUATE("THIS.Label" + ALLTRIM(STR(i)) + "3")
            WITH loObject
                .Left = 90*(IIF(i <= 4, i, i - 4) - 1) + 30
                .Top = IIF(i <= 4, 130, 260)
                .BackStyle = 0
                .Width = 64
                .Height = 18
                .Alignment = 2
                .ForeColor = IIF(i = 1, RGB(255, 0, 0), RGB(0, 0, 0))
                .FontBold = IIF(i = 1, .T., .F.)
                .Visible = .T.
            ENDWITH
        ENDFOR
        SET CENTURY ON
        SET DATE "YMD"
        THIS.GetWeatherReport()
    ENDPROC

    PROCEDURE GetWeatherReport
        PRIVATE laArray, i, loObject
        LOCAL laArray[1], i, loObject
        = GetWeather(@laArray)
        FOR i = 1 TO 8
            loObject = EVALUATE("THIS.Image" + ALLTRIM(STR(i)))
            IF laArray[i, 8] = .T.
                loObject.Picture = laArray[i, 7]
            ELSE
                loObject.Visible = .F.
            ENDIF
            loObject = EVALUATE("THIS.Label" + ALLTRIM(STR(i)) + "1")
            loObject.Caption = IIF(i = 1, "Today", DTOC(laArray[i, 1]))
            loObject = EVALUATE("THIS.Label" + ALLTRIM(STR(i)) + "2")
            loObject.Caption = laArray[i, 3]
            loObject = EVALUATE("THIS.Label" + ALLTRIM(STR(i)) + "3")
            loObject.Caption = IIF(i = 1, ALLTRIM(STR(laArray[i, 4])), ;
                ALLTRIM(STR(laArray[i, 4])) + "-" + ALLTRIM(STR(laArray[i, 5])))
        ENDFOR
    ENDPROC
   
    PROCEDURE Command1.Click
        THISFORM.GetWeatherReport()
    ENDPROC

ENDDEFINE



PROCEDURE GetWeather
    LPARAMETERS taArray
    #DEFINE WEATHER_MAIN_PAGE [http://xoap.]
    #DEFINE WEATHER_URL [http://xoap.*&dayf=10&par=0&prod=xoap&key=0&unit=m]
    #DEFINE IMAGE_PATH ADDBS(SYS(2023)) + "Weather\"
    PRIVATE llReturnValue, lcTempFile, lcData, i, lcImage, lnTemperature, lnTemperature1, lnTemperature2
    LOCAL llReturnValue, lcTempFile, lcData, i, lcImage, lnTemperature, lnTemperature1, lnTemperature2
    llReturnValue = .T.
    lcTempFile = ADDBS(SYS(2023)) + LEFT(SYS(2015), 8) + ".TMP"
    lcData = ""
    DIMENSION taArray[8, 8]
    FOR i = 1 TO ALEN(taArray, 1)
        taArray[i, 1] = DATE() + i - 1
        taArray[i, 2] = DOW(taArray[i, 1], 2)
        taArray[i, 3] = CDOW(taArray[i, 1])
        taArray[i, 4] = 0
        taArray[i, 5] = 0
        taArray[i, 6] = ""
        taArray[i, 7] = IMAGE_PATH + ALLTRIM(STR(i)) + ".GIF"
        taArray[i, 8] = .F.
    ENDFOR
    IF DIRECTORY(IMAGE_PATH) = .F.
        MKDIR (IMAGE_PATH)
    ENDIF
    TRY
        DECLARE Integer URLDownloadToFile IN URLMON.DLL Integer, String, String, Integer, Integer
    CATCH
        llReturnValue = .F.
    ENDTRY
    IF llReturnValue = .F.
        RETURN .F.
    ENDIF
    IF URLDownloadToFile(0, WEATHER_URL, lcTempFile, 0, 0) <> 0
        RETURN .F.
    ENDIF
    lcData = FILETOSTR(lcTempFile)
    IF FILE(lcTempFile) = .T.
        DELETE FILE (lcTempFile)
    ENDIF
    lcImage = ""
    lnTemperature = 0
    = GetTodayWeather(lcData, @lcImage, @lnTemperature)
    taArray[1, 6] = WEATHER_MAIN_PAGE + lcImage
    taArray[1, 4] = lnTemperature
    taarray[1, 5] = lnTemperature
    FOR i = 1 TO 7
        lcImage = ""
        lnTemperature1 = 0
        lnTemperature2 = 0
        = GetWeekWeather(lcData, i, @lcImage, @lnTemperature1, @lnTemperature2)
        taArray[i + 1, 6] = WEATHER_MAIN_PAGE + lcImage
        taArray[i + 1, 4] = lnTemperature1
        taarray[i + 1, 5] = lnTemperature2
    ENDFOR
    FOR i = 1 TO 8
        IF URLDownloadToFile(0, taArray[i, 6], taArray[i, 7], 0, 0) = 0
            taArray[i, 8] = .T.
        ENDIF
    ENDFOR
    RETURN .T.
ENDPROC

PROCEDURE GetTodayWeather
    LPARAMETERS tcData, tcImage, tnTemperature
    #DEFINE START_STRING [<table border=0 width=100%><tr><td width=50%>] + ;
        [<table border=0 cellspacing=3><tr><td width=40>]
    #DEFINE START_STRING_IMAGE [<img src="]
    #DEFINE END_STRING_IMAGE [">]
    #DEFINE START_STRING_TEMP [<br>]
    #DEFINE END_STRING_TEMP [<br>]
    PRIVATE lcString
    LOCAL lcString
    lcString = GetWordNum2(tcData, 1, START_STRING)
    tcImage = GetWordNum2(lcString, 1, START_STRING_IMAGE, END_STRING_IMAGE)
    lcString = GetWordNum2(lcString, 1, START_STRING_TEMP, END_STRING_TEMP)
    lcString = GetNumber(lcString)
    tnTemperature = INT(VAL(GETWORDNUM(lcString, 1, ",")))
    RETURN .T.
ENDPROC

PROCEDURE GetWeekWeather
    LPARAMETERS tcData, tnIndex, tcImage, tnTemperature1, tnTemperature2
    #DEFINE START_STRING2 [<table border=0 cellspacing=3 width=100%><tr><td width=50%>]
    #DEFINE START_STRING_IMAGE2 [<td width=40><img src="]
    #DEFINE END_STRING_IMAGE2 ["></td>]
    #DEFINE START_STRING_TEMP2 [<br>?放]
    #DEFINE END_STRING_TEMP2 [<br>]
    PRIVATE lcString
    LOCAL lcString
    lcString = GetWordNum2(tcData, 1, START_STRING2)
    tcImage = GetWordNum2(lcString, tnIndex, START_STRING_IMAGE2, END_STRING_IMAGE2)
    lcString = GetWordNum2(lcString, tnIndex, START_STRING_TEMP2, END_STRING_TEMP2)
    lcString = GetNumber(lcString)
    tnTemperature1 = INT(VAL(GETWORDNUM(lcString, 1, ",")))
    tnTemperature2 = INT(VAL(GETWORDNUM(lcString, 2, ",")))
    RETURN .T.
ENDPROC

PROCEDURE GetWordNum2
    LPARAMETERS tcString, tnIndex, tcLeft, tcRight
    PRIVATE lcString
    LOCAL lcString
    lcString = RIGHT(tcString, LEN(tcString) - AT(UPPER(tcLeft), UPPER(tcString), tnIndex) - LEN(tcLeft) + 1)
    IF EMPTY(tcRight) = .T.
        RETURN lcString
    ENDIF
    lcString = LEFT(lcString, AT(UPPER(tcRight), UPPER(lcString)) - 1)
    RETURN lcString
ENDPROC

PROCEDURE GetNumber
    LPARAMETERS tcString
    PRIVATE lcString, i
    LOCAL lcString, i
    lcString = ""
    FOR i = 1 TO LEN(tcString)
        IF BETWEEN(ASC(RIGHT(LEFT(tcString, i), 1)), 48, 57) = .T.
            lcString = lcString + RIGHT(LEFT(tcString, i), 1)
        ELSE
            IF EMPTY(lcString) = .F.
                IF RIGHT(lcString, 1) <> ","
                    lcString = lcString + ","
                ENDIF
            ENDIF
        ENDIF
    ENDFOR
    RETURN lcString
ENDPROC


关于VFP的天气问题

是我的网站错了吗?

图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 天气 
2013-11-04 20:08
郁郁界河
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2013-10-14
收藏
得分:0 
回复 2楼 hu9jj
还是出不了,是网站有问题吗?
两个网站是不是得输入一样的呢?
图片附件: 游客没有浏览图片的权限,请 登录注册
2013-11-05 09:52
郁郁界河
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2013-10-14
收藏
得分:0 
回复 5楼 hu9jj
额。。不太明白
2013-11-07 12:05
郁郁界河
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2013-10-14
收藏
得分:0 
回复 7楼 linkhai
有点偷懒。。。。这个,是不是我想编一个天气预报的软件只能用这样的插件呢?像敲代码的话不能实现吗?
2013-11-08 15:06
郁郁界河
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2013-10-14
收藏
得分:0 
回复 10楼 linkhai
恩,好的,谢谢!
2013-11-09 11:56
郁郁界河
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2013-10-14
收藏
得分:0 
回复 10楼 linkhai
您好,我还想请教一下,我想要就北京去年一年的天气做一下汇总和趋势分析,请问该怎么做呢?
2013-11-15 12:39
郁郁界河
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2013-10-14
收藏
得分:0 
回复 2楼 hu9jj
您好,我还想请教一下,我想要就北京去年一年的天气做一下汇总和趋势分析,请问该怎么做呢?
2013-11-18 12:26
快速回复:问什么下面这个天气抓取程序不能运行呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030464 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved