How to Save a Webpage as a local file in ASP.net ?

Discussion in 'ASP .Net' started by Kylin, May 16, 2005.

  1. Kylin

    Kylin Guest

    Kylin, May 16, 2005
    #1
    1. Advertising

  2. Kylin

    SCDeveloper Guest

    Scrape the content from an URL and save it to a file.

    In the following example, it outputs to a label.

    <%@ Import Namespace="System.Net" %>
    <script language="VB" runat="server">
    Sub Page_Load(sender as Object, e as EventArgs)
    'STEP 1: Create a WebClient instance
    Dim objWebClient as New WebClient()


    'STEP 2 and 3
    Const strURL as String = "http://www.sharingcorner.com/"
    Dim objUTF8 as New UTF8Encoding()
    lblHTMLOutput.Text =
    objUTF8.GetString(objWebClient.DownloadData(strURL))
    End Sub
    </script>

    <html>
    <body>
    <h1>Screen Scrape of www.sharingcorner.com</h1>
    <p>
    <asp:label id="lblHTMLOutput" runat="server" />
    </body>
    </html>


    SCDeveloper
    http://www.sharingcorner.com/
     
    SCDeveloper, May 16, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lyndon
    Replies:
    1
    Views:
    532
    Leonard Blaisdell
    Jul 25, 2005
  2. Replies:
    1
    Views:
    445
  3. Chris Petersen

    Automatically save a webpage as a text file

    Chris Petersen, Aug 21, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    228
    Bob Walton
    Aug 21, 2003
  4. Jack
    Replies:
    6
    Views:
    174
    Gunnar Hjalmarsson
    Feb 21, 2008
  5. soren625
    Replies:
    2
    Views:
    386
    soren625
    Dec 12, 2006
Loading...

Share This Page