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

S

SCDeveloper

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/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top