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! Search

MY FAVORITES

RECOMMENDED

Markets:
Dow:
10,711.00 -0.63%
Nasdaq:
2,368.50 -0.95%
Yahoo! Mail
Yahoo! Shopping

Shoes for Women, Men and Kids
Pumps, boots, sneakers, wedges, and more.
All the trendiest shoes are on Yahoo! Shopping.

Copyright © 2010 Yahoo! Inc. All rights reserved.


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]