Introduction
URL2File is a free ActiveX server-side component written in
Java able to save the content of a given URL to a local file.
A Java application version of
URL2File is also available, which can be run by itself on any platform with Java
support. The Windows version of URL2File can be run by
itself without Java support.
URL2File ActiveX component was originally written to be
used with Microsoft Internet Information Server (IIS) server-side scripting module, Active
Server Pages (ASP). However, it should be compatible with other software supporting
ActiveX server components. This version can also return the properties of a retrieved
file, such as its content type, URL breakdown and modified/expiration dates.
Purpose
URL2File server-side component can be used by any ASP
script that requires downloading of an HTML document or other file from a remote Internet
server to a local file, from within the script.
An example would be a search engine script with the ability
to add remote URLs or an image manipulation script with the ability to handle remote
files. Such a script would download the document at the specified URL to the local server
before manipulating it.
URL2File can also be used to generate static files out of
dynamic content. For example, a database script written to display x number of product
listings may take longer to respond and consume more server resources than a set of
multiple HTML files containing the same information. URL2File can be used in this instance
to call the database script x number of times and save the results to individual HTML
files.
Download
Download
URL2File.class ActiveX component
2.7K, updated on June 15, 1998
Installation
Since URL2File was written in Java, a Java Virtual Machine
(VM) must be installed on the server before installing the component. Microsoft Java VM is
available from:
http://www.microsoft.com/java/
Once the Java VM is successfully installed, copy
URL2File.class component to a temporary directory and run following commands from the
command prompt:
mkdir
%SystemRoot%\Java\TrustLib\Chami
copy URL2File.class %SystemRoot%\Java\TrustLib\Chami
JavaReg /register /class:Chami.URL2File /progid:Chami.URL2File
Note: JavaReg.exe is included in the Microsoft SDK for
Java.
Usage
Create an instance of the URL2File component using program
ID "Chami.URL2File" and call its primary function SaveURLToFile() with the URL
to be retrieved and the local file name to use.
ASP VBScript code sample:
<%
Set UF=Server.CreateObject("Chami.URL2File")
Set bOk=UF.SaveURLToFile("http://chami.com","temp.htm")
'if not bOk then
' Response.Write("Error: " & UF->GetLastError())
'end if
UF.Close
%>
ASP PerlScript code sample:
<%
$UF = $Server->CreateObject('Chami.URL2File');
$bOk = $UF->SaveURLToFile( 'http://chami.com','temp.htm');
if(!$bOk)
{
$Response->write( $UF->GetLastError());
}
%>
Real-world applications using URL2File:
JPEG Compressor
CodeColorizer
Reference
Primary functions:
boolean SaveURLToFile(String URL, String FileName)
Retrieve data at "URL" and save to "FileName." A boolean value
indicating success (true) or failure (false) will be returned. GetLastError() function may
be used to retrieve the error message upon failure.
String GetLastError()
Retrieve the last error message. An empty string will be returned if none of the
previous calls failed.
Support functions:
boolean SetURL(String URL)
Indicate that "URL" should be used when processing any of the following
functions. A boolean value indicating success (true) or failure (false) will be returned.
GetLastError() function may be used to retrieve the error message upon failure.
String Host()
Retrieve the host of the URL specified above.
String Server()
Retrieve the server name.
String Port()
Retrieve the port number.
String Protocol()
Retrieve the URL protocol.
String File()
Retrieve the name of the file, if applicable.
String ContentEncoding()
Retrieve the content-encoding information.
int ContentLength()
Retrieve the length of the content at the given URL.
String ContentType()
Retrieve the type of content at the given URL.
String LastModified()
Retrieve the last modified date of the URL.
long Date()
Retrieve the sending date of the URL.
long Expiration()
Retrieve the expiration date of the URL.
Disclaimer
THIS SOFTWARE IS PROVIDED ON AN AS-IS BASIS WITHOUT WARRANTY OF ANY
KIND.
PROVIDER SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY, EXPRESS OR IMPLIED,
INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL PROVIDER BE LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, SPECIAL OR
INCIDENTAL DAMAGES, EVEN IF PROVIDER HAS BEEN ADVISED BY CLIENT OF THE
POSSIBILITY OF SUCH POTENTIAL LOSS OR DAMAGE. CLIENT AGREES TO HOLD PROVIDER
HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES, LIABILITIES AND EXPENSES.
Feedback
URL2File Support
Copyright (C) 1998-2002, Chami.com
Source code colorized using CodeColorizer
|