| 1 | public class Webclient4 |
| 2 | Inherits System.Web.UI.Page |
| 3 | protected WithEvents Literal1 as System.Web.UI.WebControls.Literal |
| 4 | |
| 5 | private Sub Page_Load(ByVal sender as System.object, ByVal e as System.EventArgs) Handles MyBase.Load |
| 6 | Dim wc as new System.Net.WebClient() |
| 7 | Dim s as System.IO.Stream |
| 8 | Dim sr as System.IO.StreamReader |
| 9 | |
| 10 | 'set the header information |
| 11 | wc.Headers.Add("Accept", "*/*") |
| 12 | wc.Headers.Add("Accept-Encoding", "gzip,deflate") |
| 13 | wc.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)") |
| 14 | wc.Headers.Add("value", "this is a test") |
| 15 | |
| 16 | 'scrape the data |
| 17 | s = wc.OpenRead("http://authors.aspalliance.com/damianm/article/4/4/headreader.aspx") |
| 18 | |
| 19 | 'read in the page |
| 20 | sr = new System.IO.StreamReader(s) |
| 21 | Literal1.Text = sr.ReadToEnd() |
| 22 | End Sub |
| 23 | |
| 24 | End class |