Fetch html from other website to Your own aspx web application

Additional to RSS solution i given in

There is a way to get html data from other site in your aspx web application.
Here is the basic code.

Imports System.Net
Imports System.IO
Partial Class Default3
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sUrl As String = "any url you wanna"

            ' get a response object of given url
            Dim httpWebRequest As HttpWebRequest = DirectCast(WebRequest.Create(sUrl), HttpWebRequest)
            Dim httpWebResponse As HttpWebResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)

            Dim outputStream As New StreamReader(httpWebResponse.GetResponseStream(), System.Text.Encoding.ASCII)

            ' this writes the content to browser
            ' you may want to parse a particular section of html ?

        Catch ex As System.Exception
            Dim sError As String = "Error in viewer.aspx" & vbLf
            sError = sError + "error loading [" + sUrl + "]" & vbLf
            sError = sError + "Exception = " + ex.ToString() + vbLf

            Throw (New Exception(sError))
        End Try
    End Sub

End Class

- Vinod Kotiya


Most Viewed Post

solution for facebook waiting

Connect Sony XPLOD MEX-BT2500 Bluetooth CD Receiver with ur mobile

Crystal Report : Show data horizontally (Left to right) i.e. columns as rows

Google+ Followers