Programalama > ASP.NET

Etiketler: asp., net, ile, hava, durumu

Ort. 1
Puan ver:
<%@ 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


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.