<%@ page language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Private Sub downloadButton_OnClick(ByVal sender As Object, ByVal e As System.EventArgs)
Dim url As String = "http://xml.progen.com.tr/havadurumu.php?s=istanbul"
Dim bilgicek As String = GetHTML(url)
Dim ds As String = InStr(1, bilgicek, "<durum>")
Dim de As String = InStr(1, bilgicek, "</durum>")
Dim durum As String = Mid(bilgicek, ds, de - ds)
Dim ss As String = InStr(1, bilgicek, "<sicaklik>")
Dim se As String = InStr(1, bilgicek, "</sicaklik>")
Dim sicaklik As String = Mid(bilgicek, ss, se - ss)
Response.Write("Durum: " & durum & "<br>Sycaklyk: " & sicaklik)
End Sub
Private Function GetHTML(ByVal strURL As String) As String
Dim objResponse As WebResponse = Nothing
Dim strHTML As String
Try
Dim objUri As Uri = New Uri(strURL)
Dim objRequest As WebRequest = WebRequest.Create(objUri)
objResponse = objRequest.GetResponse
Dim objStream As Stream = objResponse.GetResponseStream
Dim encode As Encoding = System.Text.Encoding.UTF8
Dim objReader As StreamReader = New StreamReader(objStream, encode)
strHTML = objReader.ReadToEnd
Catch ex As Exception
Return ex.ToString
Finally
objResponse.Close()
End Try
Return strHTML
End Function
</script>
<form id="Form1" runat="server">
<asp:button id="downloadButton" runat="server" text="Download" tabindex="2" onclick = "downloadButton_OnClick"></asp:button>
</form>
türkay biliyor
turkay.biliyor@tekersan.com.tr