home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Netscape::History - object class for accessing Netscape history database</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Netscape::History - object class for accessing Netscape history database</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <UL>
-
- <LI><A HREF="#please note">PLEASE NOTE</A></LI>
- <LI><A HREF="#constructor">CONSTRUCTOR</A></LI>
- </UL>
-
- <LI><A HREF="#methods">METHODS</A></LI>
- <UL>
-
- <LI><A HREF="#get_url get a specific url from your history">get_url - get a specific URL from your history</A></LI>
- <LI><A HREF="#next_url get the next url from your history database">next_url - get the next URL from your history database</A></LI>
- <LI><A HREF="#delete_url remove a url from the history database">delete_url - remove a URL from the history database</A></LI>
- <LI><A HREF="#add_url add a url to the history database">add_url - add a URL to the history database</A></LI>
- <LI><A HREF="#rewind reset internal url pointer to first url in history">rewind - reset internal URL pointer to first URL in history</A></LI>
- <LI><A HREF="#close close the history database">close - close the history database</A></LI>
- </UL>
-
- <LI><A HREF="#examples">EXAMPLES</A></LI>
- <UL>
-
- <LI><A HREF="#display contents of history">DISPLAY CONTENTS OF HISTORY</A></LI>
- <LI><A HREF="#merge two history files">MERGE TWO HISTORY FILES</A></LI>
- </UL>
-
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- <LI><A HREF="#copyright">COPYRIGHT</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Netscape::History - object class for accessing Netscape history database</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- use Netscape::History;
- </PRE>
- <PRE>
-
- $history = new Netscape::History();
- while (defined($url = $history->next_url() ))
- {
- }</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>The <CODE>Netscape::History</CODE> module implements an object class for
- accessing the history database maintained by the Netscape web browser.
- The history database keeps a list of all URLs you have visited,
- and is used by Netscape to change the color of URLs which you have
- previously visited, for example.</P>
- <P>With this module, you can get at the URLs stored in a Netscape history
- file, delete URLs, and add new ones. With the associated
- <A HREF="#item_Netscape%3A%3AHistoryURL"><CODE>Netscape::HistoryURL</CODE></A> module you can access the information which
- is associated with each URL.</P>
- <P><STRONG>Please Note:</STRONG> the database format for the browser history was changed
- with Netscape 4. Previously only the time of most recent visit was
- available; now you can also get at the time of your first visit,
- the number of visits, the title of the referenced page, and another value.</P>
- <P>
- <H2><A NAME="please note">PLEASE NOTE</A></H2>
- <P>In version 2.00 of this module, you had to set the
- <CODE>$Netscape::History::NETSCAPE_VERSION</CODE> variable
- to the major version number of the Netscape you were using,
- since there was a change in the information stored for each URL
- between versions 3 and 4.
- In a subsequent version we removed the need for the variable,
- thanks to a suggestion from Jimmy Aitken.</P>
- <P>Previously, setting the variable would silently do nothing,
- from this version onwards it will result in an error.</P>
- <P>
- <H2><A NAME="constructor">CONSTRUCTOR</A></H2>
- <PRE>
- $history = new Netscape::History();</PRE>
- <P>This creates a new instance of the Netscape::History object class.
- You can optionally pass the path to the history database as an
- argument to the constructor, as in:</P>
- <PRE>
- $history = new Netscape::History('/home/bob/.netscape/history.db');</PRE>
- <P>If you do not specify the file, then the constructor will use:</P>
- <PRE>
- $HOME/.netscape/history.db</PRE>
- <P>If the Netscape history database does not exist, a warning message
- will be generated, and the constructor will return <A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A>.</P>
- <P>
- <HR>
- <H1><A NAME="methods">METHODS</A></H1>
- <P>The <STRONG>Netscape::History</STRONG> class implements the following methods:</P>
- <UL>
- <LI>
- get_url - get a specific URL from your history
- <P></P>
- <LI>
- rewind - reset history database to first URL
- <P></P>
- <LI>
- next_url - get next URL from your history
- <P></P>
- <LI>
- delete_url - remove a URL from your history
- <P></P>
- <LI>
- add_url - add a URL to the history file
- <P></P>
- <LI>
- close - close the history database
- <P></P></UL>
- <P>Each of the methods is described separately below.</P>
- <P>
- <H2><A NAME="get_url get a specific url from your history">get_url - get a specific URL from your history</A></H2>
- <PRE>
- $url = $history->get_url( URL );</PRE>
- <P>This method is used to extract information about a specific URL
- from your history database.</P>
- <P>This method takes a URL (which could be just a text string,
- or an object of class URI::URL) and returns an instance
- of Netscape::HistoryURL.</P>
- <P>
- <H2><A NAME="next_url get the next url from your history database">next_url - get the next URL from your history database</A></H2>
- <PRE>
- $url = $history->next_url();</PRE>
- <P>This method returns the next URL from your history database.
- If you want to process all URLs in the database, you
- should call the <STRONG>rewind</STRONG> method before looping over all URLs.</P>
- <P>The URL returned is an instance of the Netscape::HistoryURL class,
- which works just like an instance of URI::URL, but provides an
- extra methods, as described in the documentation for Netscape::HistoryURL.</P>
- <P>
- <H2><A NAME="delete_url remove a url from the history database">delete_url - remove a URL from the history database</A></H2>
- <PRE>
- $history->delete_url($url);</PRE>
- <P>This method is used to remove a URL from your history database.
- The URL passed can be a simple text string with the URL,
- or an instance of Netscape::HistoryURL, URI::URL, or any other
- class which can be rendered into a string.</P>
- <P>
- <H2><A NAME="add_url add a url to the history database">add_url - add a URL to the history database</A></H2>
- <PRE>
- $history->add_url( URL );</PRE>
- <P>This method is used to add a URL to a history database.
- This might be useful if you are merging information from multiple
- history databases, for example.</P>
- <P>If the URL passed is an instance of Netscape::HistoryURL,
- then the information available will be stored.</P>
- <P>If the URL is specified as a text string, is derived from URI::URL,
- then a Netscape::HistoryURL will be created with the following:</P>
- <PRE>
- LAST = current time
- FIRST = current time
- COUNT = 1
- EXPIRE = 1
- TITLE = ''</PRE>
- <P>If the EXPIRE field is not set to 1, then it won't appear
- in Netscape's history window. Not really sure why :-)</P>
- <P>
- <H2><A NAME="rewind reset internal url pointer to first url in history">rewind - reset internal URL pointer to first URL in history</A></H2>
- <PRE>
- $history->rewind();</PRE>
- <P>This method is used to move the history database's internal pointer
- to the first URL in your history database.
- You don't need to bother with this if you have just created the object,
- but it doesn't harm anything if you do.</P>
- <P>
- <H2><A NAME="close close the history database">close - close the history database</A></H2>
- <PRE>
- $history->close();</PRE>
- <P>This closes the history database. The destructor will do this automatically
- for you, so most of time you don't actually have to bother calling this
- method explicitly. Good programming style says you should though :-)</P>
- <P>
- <HR>
- <H1><A NAME="examples">EXAMPLES</A></H1>
- <P>
- <H2><A NAME="display contents of history">DISPLAY CONTENTS OF HISTORY</A></H2>
- <P>The following example illustrates use of this module,
- and the <STRONG>visit_time()</STRONG> method of the URLs returned.
- The program will list all URLs visited, along with visit time.
- The Date::Format module is used to format the visit time.</P>
- <PRE>
- #!/usr/bin/perl -w
- </PRE>
- <PRE>
-
- use Netscape::History;
- use Date::Format;
- use strict;</PRE>
- <PRE>
-
- my $history;
- my $url;</PRE>
- <PRE>
-
- $history = new Netscape::History;
- while (defined($url = $history->next_url() ))
- {
- print "$url :\n";
- print " First : ", ctime($url->first_visit_time());
- print " Last : ", ctime($url->last_visit_time());
- print " Count : ", $url->visit_count(), "\n";
- print " Expire : ", $url->expire(), "\n";
- print " Title : ", $url->title(), "\n";
- }
- $history->close();</PRE>
- <P>
- <H2><A NAME="merge two history files">MERGE TWO HISTORY FILES</A></H2>
- <P>The following example illustrates use of the <CODE>add_url</CODE> method
- to merge two history databases. We read all URLs from <CODE>history2.db</CODE>,
- and merge them into <CODE>history1.db</CODE>, overwriting any duplicates.</P>
- <PRE>
- $history1 = new Netscape::History("history1.db");
- $history2 = new Netscape::History("history2.db");
- while (defined($url = $history2->next_url() ))
- {
- $history1->add_url($url);
- }
- $history1->close();
- $history2->close();</PRE>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <DL>
- <DT><STRONG><A NAME="item_Netscape%3A%3AHistoryURL"><A HREF="../../../site/lib/Netscape/HistoryURL.html">the Netscape::HistoryURL manpage</A></A></STRONG><BR>
- <DD>
- When you call the <EM>next_url</EM> method, you are returned instances of this class.
- <P></P>
- <DT><STRONG><A NAME="item_DB_File"><A HREF="../../../lib/DB_File.html">the DB_File manpage</A></A></STRONG><BR>
- <DD>
- The Netscape history file is just a Berkeley DB File,
- which we access using the <A HREF="#item_DB_File"><CODE>DB_File</CODE></A> module. You can
- use a different DB_File compatible library (such as
- <CODE>DB_File::SV185</CODE>) by running
- <PRE>
- use Netscape::History dblib => 'DB_File::SV185'</PRE>
- <P>in which case you are only depending on the specified
- library and not <A HREF="#item_DB_File"><CODE>DB_File</CODE></A>.</P>
- <P></P>
- <DT><STRONG><A NAME="item_URI%3A%3AURL"><A HREF="../../../site/lib/URI/URL.html">the URI::URL manpage</A></A></STRONG><BR>
- <DD>
- The underlying class for <A HREF="../../../site/lib/Netscape/HistoryURL.html">the Netscape::HistoryURL manpage</A>,
- which provides the mechanisms for manipulating URLs.
- <P></P>
- <DT><STRONG><A NAME="item_Date%3A%3AFormat"><A HREF="../../../site/lib/Date/Format.html">the Date::Format manpage</A></A></STRONG><BR>
- <DD>
- Functions for formatting time and date in strings.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Neil Bowers <<A HREF="mailto:neilb@cre.canon.co.uk">neilb@cre.canon.co.uk</A>>, and
- Richard Taylor <<A HREF="mailto:rit@cre.canon.co.uk">rit@cre.canon.co.uk</A>>.</P>
- <P>
- <HR>
- <H1><A NAME="copyright">COPYRIGHT</A></H1>
- <P>Copyright (c) 1997-1999 Canon Research Centre Europe. All rights reserved.
- This module is free software; you can redistribute it and/or modify
- it under the same terms as Perl itself.</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Netscape::History - object class for accessing Netscape history database</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-