Potential Extension: Adding User Control
As mentioned earlier, this application leaves users at the “mercy” of the search engine defaults. That is, users have little or no control over customizing their searches. The only thing the user has to enter is the query text. You can code it so that users can also effect such features as the number of results to return per page, the amount of information displayed with each result, or perhaps whether to impose Boolean search rules with terms such as AND, OR, LIKE, and NOT LIKE. In this section, I’ll use the HotBot search engine as an example.
Perhaps the easiest way to extend functionality is to increase the number of results per page. You’ll need the name-value pair associated with the results per page for each search engine. Table 4.2 lists a few names and possible values for several search engines.
Table 4-2. Search Engines and Variables for Determining the Result Count
|
Search Engine |
Field name |
Possible values |
Example |
|---|---|---|---|
|
HotBot |
|
10, 25, 50, 100 |
|
|
InfoSeek Advanced Search |
|
10, 20, 25, 50 |
|
|
Scientific American |
|
10, 25, 50, 100 |
|
|
Yahoo! |
|
10, 20, 50, 100 |
|
I pulled these field names from the source code of each search page. Some of the fields come from the search engine’s advanced search pages, so the URLs in the engines array might not work. Keep in mind, too, that the number of results might not be adjustable. The search engine coders may have it set ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access