Start your engines

Designing your own search engine for a site has, until recently, been fiendishly difficult, involving no small amount of skill in scripting languages or creating databases. To be honest, a fully-customised, searchable database still requires considerable ability, and I'll probably look at your options for creating such a search engine in MySQL some time in the near future.

In the meantime, the Web provides a number of alternatives in the form of ready-made scripts or third-party resources that are easier to adapt.

Perl and simple searches

If you have access to the cgi-bin on your Web site, one tried-and-trusted way to set up a search engine is using a Perl script which is very competent at ploughing through Web pages looking for text.

There are plenty of Perl-based Web searches available online, the most widely used being Simple Search (www.scriptarchive.com/search.html). Here, because it is slightly easier to set up (and it's got a great name), we'll be using Jason Anthony's Jasearch (www.ufbs.co.uk/jason/perl/jasearch.html) - see screen shot.

Jasearch has two components, the HTML search form and a script engine, jasearch.pl. This script is particularly easy to set up because it will probably require no modification at all - so long as your first line points to the appropriate location of Perl (for example, #!/usr/bin/perl) as all variables are set up in your Web page.

After you've loaded jasearch.pl to an appropriate cgi-bin directory on your server, you create a Web form that includes the following code:

&lt form method="post" action="cgi-bin\jasearch.pl" &gt &lt input type="hidden" name="base" value="../yourdirectory" &gt &lt input type="hidden" name="rbase" value="http://www.yoursite.com" &gt Search for &lt input type="text" name="sv" value="" &gt &lt input type="submit" value="Search" &gt &lt input type="reset" value="Reset" &gt &lt /form &gt

Back to base

You will be able to add these buttons and fields in pretty much any Web editor, but the values for the various hidden and text fields (base, rbase and sv) are important.

Base indicates the directory you want to search on your server, while rbase provides the URL. The name sv for the text search box is the standard variable used within jasearch.pl itself - while it is possible to change this, you will then need to modify the perl script. With the code in place as listed above, any words entered into your text field sv will be posted to the Jasearch Perl script and results returned to a pre-created search results page.

Within the jasearch.pl script, you'll find the parameters to modify the format of this page. Of course, you should adapt your initial search form to match the look and feel of your site.

JavaScript searches

Perl was designed to work with text documents and has the advantage of being supported across many Web sites, but if you don't have access to a cgi-bin folder it can be impossible to implement.

Instead, you could use Java­Script code to provide text searches that do not need access to Perl, executable files or any other scripting languages on the server. The downside, of course, is that any visitor who turns off scripting will not be able to access your search engine. JavaScript searches work either by trawling a basic text file/database that you load on to your site with your Web pages, or by linking to an engine that's run by a third party. I've thrown together a few details about the latter (see "Add hassle-free searches with FreeFind"), but another, more recent launch is AddSearch, which provides a free plug-in for your site - see here.

The X factor

Of the flat-file database searches, one good source is XSearch 5.2: this was developed by Dynamic Core, although it doesn't appear to offer support for it any longer, and the original Web site has been closed (www.dynamic-core.net). A search in Google will turn up plenty of sites where you can download the code - including the all-important db.js files - and an editor is also available at http://xseditor.free.fr to help take some of the tedium out of creating your database. Of course, you could just head to the cover disc instead.

Alternatively, at www.trans4mind.com/personal_development/javascript/searchengine.htm you'll find the JavaScript code for search­ing through a number of URLs or metatags on your site. As the author suggests, the JavaScript Editor is an easier way to generate such code and you can download a 30-day trial from the same site.

If you want a world-class search engine, it's also worth bearing in mind that Google has started making available its API (application programming interface). The service is still in beta and restricted to 1000 searches a day - and you'll need some skills to integrate it into your site via XML - but it offers enormous potential. For more information, go to www.google.co.uk/apis.

Sites OF THE MONTH While not dedicated to search engines per se, you will find customisable scripts for these as well as nearly 6000 others at ScriptSearch (www.scriptsearch.com). Quantity itself is no guarantee of quality, but there are some great Web widgets available here, whether you need a free subscription manager, shopping cart scripts or remotely hosted bulletin boards. Scripts are available in a wide range of languages, including ASP, Flash and Python as well as Perl and PHP.

Add hassle-free searches with FreeFind

If you want to create a search engine with the minimum of programming - and cost - another alternative is to use a remotely hosted engine such as that provided by FreeFind (details at www.freefind.com). Once you've registered the details of your site and a username/current e-mail, log on to the control centre at control.freefind.com to use FreeFind to generate a search engine for your site.

This process consists of two parts: first of all, you need to generate an index of your site by clicking on the Build Index tab. You can schedule this to take place at a certain time, or click the Index now link - it may take up to 24 hours to complete. You can also specify advanced options such as whether to index PDFs or exclude certain areas.

After your site has been indexed, click on the HTML tab to create the code you need to access the search engine. Simply copy and paste the HTML provided to create a simple search box and button that you can then customise in your favourite Web editor.

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Jason Whittaker

PC World
Show Comments

Father’s Day Gift Guide

Brand Post

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Luke Hill

MSI GT75 TITAN

I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Laura Johnston

MSI GS65 Stealth Thin

If you can afford the price tag, it is well worth the money. It out performs any other laptop I have tried for gaming, and the transportable design and incredible display also make it ideal for work.

Andrew Teoh

Brother MFC-L9570CDW Multifunction Printer

Touch screen visibility and operation was great and easy to navigate. Each menu and sub-menu was in an understandable order and category

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?