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. Advertisements

  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. Advertisements

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. ilir
    Replies:
    0
    Views:
    469
  2. Mike
    Replies:
    2
    Views:
    1,699
    David Graham
    Nov 13, 2003
  3. Lyndon
    Replies:
    1
    Views:
    681
    Leonard Blaisdell
    Jul 25, 2005
  4. Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

    Re: Local ASPX pages won't diaplay - IE and Firefox ask to open or save file

    Steve C. Orr [MCSD, MVP, CSM, ASP Insider], Jun 21, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    944
    Cyril Gupta
    Jun 21, 2008
  5. Shahar Golan
    Replies:
    5
    Views:
    451
    kaeli
    Oct 16, 2003
  6. Chris Petersen

    Automatically save a webpage as a text file

    Chris Petersen, Aug 21, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    333
    Bob Walton
    Aug 21, 2003
  7. Jack
    Replies:
    6
    Views:
    293
    Gunnar Hjalmarsson
    Feb 21, 2008
  8. soren625
    Replies:
    2
    Views:
    690
    soren625
    Dec 12, 2006
Loading...