Building a Private Search Engine Using ASP
Many web enthusiasts, when creating their personal homepages, rack their brains to make the functionality of their websites more comprehensive. Here, the author introduces a method to build your own search engine using ASP.
Basic Idea: Use a form to store the search keywords submitted by users in a variable and submit them for processing by an ASP script. Use the built-in "REQUEST" object in ASP to obtain the key characters from the variable, then use the "REDIRECT" function of "RESPONSE" to redirect the key characters to other professional search engines like Sohu or NetEase, thereby obtaining search results. This allows visitors to conveniently use major search engines directly on your homepage without needing to log in to their main pages.
Step 1: Create the main page for the search engine. Add the following code between the `` and `` tags in your HTML file:
```html
Please select your preferred search engine
Sohu
Sina (Beijing Station)
NetEase
Please enter the keyword you want to search
```
Here, we provide three search engines—Sohu, Sina, and NetEase—for users to choose from. After entering the keyword string, the form will submit the request to the backend `search.asp` for processing.
Step 2: Write the backend ASP program. Add the following code between the `` and `` tags in your HTML file:
```asp
```
When submitting the search string to other search engines, a crucial point is understanding the query format used by these search engines. For example, Sohu uses the format "http://site.search.sohu.com/sitesearch.jsp?key_word=" followed by the search string. By paying attention to the addresses displayed in the IE address bar when using these search engines, you can analyze and record the query format after removing the trailing characters such as "%C1%F5%" (which are converted forms of the submitted search string).
Additionally, many search engines offer categorized searches, such as "Website," "Webpage," and "News." Each category has its own unique query format. Readers can add more IF statements to create selection options, enabling finer categorization within the same search engine.
Similarly, this program can be expanded by adding other search engines, making it even more powerful.