E:\web\learnaspcom\htdocs\freebook\learn\ubtoc.xml LearnAsp.com - ASP ASP.net Free Lessons
Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll
<Asp.net blog>
<personal site>
xxx

Utility Belt: HTTPGrab
by Charles Carroll

The code below shows "Utility Belt" grabbing  the content of a URL and the second example shows the same thing with caching applied.

Here is the standard URL scraper.

   filename=/experiments/utilitybelt/vercurrent/ubdemo_httpgrab.aspx

<Test Script Below>


<%@ debug="true" %>
<%@ Assembly src="utilitybelt.vb" %>
<script language="VB" runat="server">
    dim ub1 as new LearnAsp.utilitybelt()
Sub Page_Load(S As Object, E As EventArgs)
    ub1.Options("Trace-On")
    litscrape.text=server.htmlencode(ub1.HttpGrab("http://www.cnn.com"))
End Sub
</script>
<html><head>
<title>Xray HTTP Demo</title>
</head>
<body bgcolor="#FFFFFF">
<form runat="server">
<asp:literal id="litScrape" runat="server" />
</form>
</body></html>

Here is the standard URL scraper that is cached so that no matter tow many times a URL is requested it is fetched out of the cache instead for the duration.

   filename=/experiments/utilitybelt/vercurrent/ubdemo_httpgrab_cached.aspx

<Test Script Below>


<%@debug="true" %>
<%@ Assembly src="utilitybelt.vb" %>
<script language="VB" runat="server">
    dim ub1 as new LearnAsp.utilitybelt()
Sub Page_Load(S As Object, E As EventArgs)
    ub1.Options("trace-on,cache-on")
    ub1.intCacheMinutes=20
    litscrape.text=server.htmlencode(ub1.HttpGrab("http://www.cnn.com"))
End Sub
</script>
<html><head>
<title>Xray HTTP Demo</title>
</head>
<body bgcolor="#FFFFFF">
<form runat="server">
<asp:literal id="litScrape" runat="server" />
</form>
</body></html>
Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site