问什么下面这个天气抓取程序不能运行呢?
程序代码:
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的天气问题
是我的网站错了吗?