|
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
<%@ 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
<%@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>
|