我多年来一直使用 Yahoo Weather API XML 格式,并在最近几周注意到这个新错误。我试图向https://developer.yahoo.com/weather/support报告该错误,但找不到 404 页面。如果等于当前日期,我决定解析返回的日期,如果不等于 re-call sub,则继续。这样我总能得到当前的天气,但不幸的是,这是很多不必要的流量/请求,也许 YDN 会意识到并修复。但无法报告我不知道。我知道这不是解决办法,而是创可贴,祝你好运!
Private Sub btnWeather_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeather.Click
If InternetConnection() = False Then
MsgBox("No internet connection!", vbExclamation, "Oops!")
Exit Sub
Else
'MsgBox("Internet connection detected!", vbInformation, "Huray!")
btnWeather.Enabled = False
lblWorking.Text = "Working ..."
tbTries.Text = "1"
Try
Dim t As New clsWeather(Format(Me.TxtBoxZIP.Text), "f")
lblTodaysDate.Text = FormatDateTime(Now.Date, DateFormat.ShortDate)
tbHigh.Text = t.high & "°"
lblCity.Text = TxtBoxZIP.Text & " Weather "
tbLow.Text = t.Low & "°"
tbDay.Text = t.day
tbDate.Text = t.date1
tbCurrenttemp.Text = t.currenttemp & "°"
tbCurrentCode.Text = t.currentcode
tbForcastCode.Text = t.ForcastCode
tbSunrise.Text = t.Sunrise
tbSunset.Text = t.Sunset
tbWind.Text = CInt(Val(t.Wind)) & " mph"
tbHumidity.Text = CInt(Val(t.humidity))
imgWeather.Image = Image.FromFile(t.GetImage)
CodeName()
If t.currenttemp < 85 And t.currenttemp > 45 Then
lblFeelsLike.Text = ""
tbFeelsLike.Text = ""
End If
If t.currenttemp > 85 Then
lblFeelsLike.Text = "Heat Index:"
Dim Temp = t.currenttemp
Dim RH = CInt(Val(t.humidity))
tbFeelsLike.Text = (-42.379 + 2.04901523 * Temp) + (10.14333127 * RH) - (0.22475541 * Temp * RH) - (0.00683783 * Temp * Temp) - (0.05481717 * RH * RH) + (0.00122874 * Temp * Temp * RH) + (0.00085282 * Temp * RH * RH) - (0.00000199 * Temp * Temp * RH * RH)
Dim num As Decimal = CType(tbFeelsLike.Text, Decimal)
Me.tbFeelsLike.Text = String.Format("{0:n0}", num)
tbFeelsLike.Text = tbFeelsLike.Text & "°"
End If
If t.currenttemp < 45 Then
lblFeelsLike.Text = "Wind Chill:"
tbFeelsLike.Text = CInt(Val(t.Chill)) & "°"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Dim day As String = DateTime.Now.ToString("dd")
If day = tbDate.Text = True Then
tbDate1.Text = tbDate.Text
btnWeather.Enabled = True
lblWorking.Text = ""
Else
btnWeather_Click(sender, e)
tbTries.Text = tbTries.Text + 1
End If
End Sub