Screen Scrape of www.yahoo.com

This demo illustrates how to perform a screen scrape using the WebClient class. Note that only a few lines of code are needed. (With classic ASP, to perform screen scrapes you needed to use a third-party component.) To view the actual HTML returned by the screen scrape, do a View/Source.


Yahoo Yahoo


Source Code:
<%@ 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.yahoo.com/"
    Dim objUTF8 as New UTF8Encoding()
    lblHTMLOutput.Text = objUTF8.GetString(objWebClient.DownloadData(strURL))
  End Sub
</script>

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


[Return to the Article]