Building a private search engine using ASP

Source: Internet
Author: User
Tags format key string query
Many network enthusiasts in the creation of their own personal homepage, have racked their brains to make their site more comprehensive function. Here, the author introduces a method of using ASP to establish own search engine.

Basic ideas use forms to store user-submitted search keywords in variables and submit them to ASP script processing. Using the ASP Built "REQUEST" object to obtain the key characters in the variable, then use "RESPONSE" "REDIRECT" function will be the key characters to other such as Sohu, NetEase and other professional search engines, you can get the search results. Make it easy for visitors to use the major search engines on their home page, without having to log on to their main pages.

The first step is to create the homepage of the search engine. In the HTML file
The following code is added between the body> and the/body>:

Form Name= "Form1" method= "Post" action= "Search.asp"

"Div align=" center "Please choose your favorite search engine" br>< br>

Select Name= "Select" size= "1"

option> Sohu/option>

option> Sina (Beijing railway station)/option>

option> NetEase/option>

/select>< br>< br>

Please type the keyword you want to query on br>

Input type= "text" Name= "TextField"

br>< br>

"Input type=" submit "name=" submit "style=" color: #CC0033; Background-color: #ffffff; Font-size:9pt;border: #CC0033 1px solid;height:18px "value=" "Search"

/form>

In this, we provide Sohu, Sina, NetEase 3 kinds of search engine for user to choose, the user type the key string, the form will request submits to the backstage search.asp processing.

The second step is to write the background of the ASP program. Add the following code between the body> and the/body> of the HTML file:

% if Request.Form ("select") = "Sohu" then Response.Redirect ("http://site.search.sohu.com/

Sitesearch.jsp?key_word= "&&request.form (" TextField ")) End If

If Request.Form ("select") = "Sina (Beijing Station)" then Response.Redirect ("http://site.search.sohu.com/

Sitesearch.jsp?key_word= "&&request.form (" TextField ")) End If

If Request.Form ("select") = "NetEase" then Response.Redirect ("http://search.163.com/cgi-bin/search/engine/ Search2.fcgi?lang=gb&&key= "&&request.form (" TextField")) End If

%>

When implementing a submit search string to another search engine, it is important to understand the query format used by these search engines. such as Sohu use is "http://site.search.sohu.com/sitesearch.jsp?key_word=" search string. We just need to keep in mind when using these search engines, when the search results are given, the address of the IE address bar is recorded and analyzed, then the query format can be obtained by removing the following characters, such as "%c1%f5% ..." character (which is the character of the search string we submitted).

In addition, many search engines use the category lookup. Can be subdivided into "website", "page", "News" and other categories, each kind of query format is not the same, readers can use more if statements to create options to achieve the same search engine within the classification of search.
By the same token, we can also expand the program to add other search engines to make it more powerful.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.