1. Link directly to the Terms of Use page
To link directly to the official Terms of Use page, add the following
anchor tag to your HTML source code.
<a href="http://www.policy.ucsb.edu/terms_of_use/">Terms of Use</a>
|
2. Add the source document to your Web page using PHP,
Perl, ASP, and .NET
Since the content is separate from the design, "including" the
source document's content in your Web page allows you to customize
its look and feel. The following examples show how to "include" the
source document using PHP, Perl, ASP, and .NET.
2a. Sample use of PHP code to "include" document
into your Web site.
You can use the following code sample using PHP
to include the source document into your Web page.
<?php
readfile("http://www.policy.ucsb.edu/terms_of_use/content.html");
?>
|
2b. Sample use of Perl code to "include" document
into your Web site.
You can use the following code sample using Perl
to include the source document into your Web page.
- Set the Library for WWW in Perl (LWP) to use the 'Simple'
module.
- Store the data you want to scrape in a scalar variable
which holds both strings and numbers interchangeably.
- Call the get or getprint function to display the URL
document.
- Use an 'include' with the perl script and paste
it into the body portion of your HTML. This is one of several
methods of displaying the document with Perl.
#!/usr/bin/perl
use LWP::Simple;
## store remote page in scalar variable
print "Content-type:text/html\n\n";
## or just get and print
getprint("http://www.policy.ucsb.edu/terms_of_use/content.html");
EXAMPLE:
<html>
<body>
<!--#include virtual="/cgi-restricted/terms-of-use.pl"-->
</body>
</html>
|
2c. Sample use of Classic ASP code to "include" document
into your Web site.
Classic ASP on IIS 4.0 and 5.0 does not allow
you to do includes from a remote Web server in the same way PHP
does. To do a "screen scrape" with classic ASP, you
need to use a third-party component that does the necessary HTTP
spoofing, like SoftWing's free
AspTear.
Once you download and install AspTear, you
include code in your ASP page to do the following:
- Set AspTear constants and create the AspTear object.
- Call the Retrieve method, passing in the URL whose data
you want to scrape, the action, and optional parameters.
- Write out the string that the method returns.
<%
'AspTear constants
Const Request_POST = 1
Const Request_GET = 2
Set objTear = CreateObject("SOFTWING.ASPtear")
Response.ContentType = "text/html"
On Error Resume Next
Dim strRetval
' Parameters: URL, action, payload, username, password
strRetval = objTear.Retrieve("http://www.policy.ucsb.edu/terms_of_use/content.html",
Request_GET, "", "", "")
' Error checking
If Err.Number <> 0 Then
Response.Write "<b>"
If Err.Number >= 400
Then
Response.Write "Server
returned error: " & Err.Number
Else
Response.Write "Component/WinInet
error: " & Err.Description
End If
Response.Write "</b>"
Response.End
End If
Response.Write strRetval
%> |
2d. Sample use of ASP.Net code to "include" document
into your Web site.
With ASP.Net, unlike classic ASP, you do not
need to use a separate component to perform a screen scrape.
Instead you can use the System.Net namespace's WebClient class to do the
following:
- Create an instance of the WebClient class.
- Call the DownloadData method, passing in the URL whose
data you want to scrape. A Byte array will be returned.
- Convert the Byte array to a string.
*Note: If your Web server is behind a proxy,
the WebClient class won't work; instead, you will need to use
the HttpWebRequest class.
<%@
Import Namespace="System.Net" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object,
e as EventArgs)
'Create
a WebClient instance
Dim
objWebClient as New WebClient()
'Set
string constant to URL you want to scrape
Const
strURL as String = "http://www.policy.ucsb.edu/terms_of_use/content.html"
'Create
a UTF8Encoding instance for byte to string conversion
Dim
objUTF8 as New UTF8Encoding()
'Call
the DownloadData method and convert byte array to string
lblHTMLOutput.Text
= objUTF8.GetString(objWebClient.DownloadData(strURL))
End Sub
</script>
<html>
<body>
<h3>Screen Scrape of
http://www.policy.ucsb.edu/terms_of_use/content.html
</h3>
<p>
<asp:label id="lblHTMLOutput" runat="server" />
</body>
</html>
|
3. Customized Terms of Use Page
If your organization needs to modify the Terms of Use document
for a specific purpose, you should submit the modified version
for approval to
policy@ucsb.edu.
If the Coordinator approves the modified content, the updated
version can be used and a copy will be retained by Administrative
Services.