Use http components to implement multi-engine search

Source: Internet
Author: User

ASP (Active Server Page) technology greatly facilitates database access in the network, and because ASP requires so many requests different from CGI (reducing server resource usage ), the combination of ASP and Windows NT and 2000 makes ASP technology widely used in today's Internet. However, I don't know if you have thought about it carefully! ASP, in addition to using ADO to access the database and use of several other built-in components, cannot do anything else. Compared with programs such as Perl and PHP, ASP functions seem very simple, there is also a lack of functions, but the old one is the old one. He left a hand for everyone, that is, ASP components (about the concept of components, now there are a lot of components, you should not make a mistake ), through component development, you can do everything that other languages (such as PHP, Perl, and C ++) can do, even in some aspects, this article tries to show you the powerful functions of ASP components. However, due to ASP components (non-registered components are used), they may sometimes become unstable, however, this article tries to show you something and provide you with a way of thinking, rather than others, so I am sorry for the shortcomings!
Code idea: Generally, we submit a form to a search engine program, and the search engine obtains the submitted data and then processes it and returns the result. However, such a thing actually gets a submitted variable, we can use another method of directly following the connection to access the search engine, for example, you can use the Yeah homepage to search for a keyword "xuankong", you can also use the following connection "http://search.163.com/cgi-bin/search/engine/search.fcgi? Key = xuankong "to get the use result. This article uses the HTTP component of ASP to access this direct connection, get to get the data originally returned on the web page, and then output it.

If this component can implement multithreading (if so, data can be obtained for different engines at the same time without having to perform a single access and then get results) and further code optimization and improvement, this will greatly save your time and allow you to return results of multiple engines at the same time in a single search!

Note: The search results are invalid because the categories of some engines use relative connections. (You can handle these results, but I am too lazy, so I don't want to spend that time), but the connection between all websites and webpages is effective. The Code provided in this article is only suitable for testing and not for specific applications. If you need specific applications, use appropriate HTTP components, or write multi-threaded components by yourself if you are a programmer.

Code start:
<! --
This Code uses the HTTP component and zookeeper, the father of zookeeper, is a powerful tool provided by the Alliance. the powerful features of the SP component!
This component is not a registered component and may have certain functional limitations. It also searches for several engines at the same time (the search engine can be expanded at will, but it may affect the speed ), therefore, it takes a long time for the system to output data. Please wait patiently before using this code, please download http://www.serverobjects.com/comp/asphttp3.zip, and then compress it to your system32directory (winnt or Win2000)
Use regsvr32 asphttp. DLL to register this component, copy this file to the relevant IIS Executable Directory, and use IE or Netscape to browse
-->
<%
'Determine whether to output the page or process data, and then call different parts
Keyword = trim (request. Form ("keyword "))
If isnull (keyword) or keyword = "" then
%>
<! --
HTML page code Display
-->
<HTML>
<Head>
<Title> aspcn. com super search engine </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta name = "author" content = "Pu Junjie">
<Meta name = "keywords" content = "ASP, component, www.aspcn.com">
<Style type = "text/CSS">
<! --
Table {font-size: 9pt; font-style: normal}
Test {border: 1px #000000 dashed; border-color: #000000 none}
Test1 {background-color: # ccffcc; clip: rect (); font-size: 9pt; font-style:
Normal; border-style: dashed; border-top-width: 1px; border-right-width: 1px;
Border-bottom-width: 1px; border-left-width: 1px}
-->
</Style>
</Head>
<Body bgcolor = "# ffffff" leftmargin = "0" topmargin = "0" marginwidth = "0" marginheight = "0">
<Table width = "75%" border = "1" align = "center" Height = "20" cellpadding = "0"
Cellspacing = "1" bgcolor = "#66cc99" bordercolor = "# ffffff">
<Tr>
<TD Height = "4">
<Div align = "center"> <font color = "#000000" size = "2"
Face = "Arial"> aspcn. com </font> <font color = "#000000" size = "3"
Face = "Arial"> </font> <B> <font color = "#000000" size = "3" face = "Arial">
</Font> <font color = "#000000" size = "3" face = "_ gb2312"> super search engine </font> </B> </div>
</TD>
</Tr>
<Tr bordercolor = "#66cc99">
<TD Height = "21"> select the following search engine: (Note: This search engine is only suitable for <font color = "# ffffff"> Web Search </font>) </TD>
</Tr>
<Tr bordercolor = "# ffffff" align = "center" valign = "TOP">
<TD Height = "20">
<Form method = "Post" Action = "HTTP. asp">
<Table width = "96%" border = "0" Height = "21" align = "center">
<Tr>
& Lt; TD Height = "10" width = "31%" & gt;
<Div align = "right"> enter the keyword you want to search for: </div>
</TD>
& Lt; TD Height = "10" width = "69%" & gt;
<Input type = "text" name = "keyword" class = "test">
</TD>
</Tr>
<Tr>
& Lt; TD Height = "2" width = "31%" & gt;
<Div align = "right"> select your search engine: </div>
</TD>
& Lt; TD Height = "2" width = "69%" & gt;
<Input type = "checkbox" name = "yeah" value = "yeah">
Yeah
<Input type = "checkbox" name = "yahoo" value = "yahoo">
Yahoo
<Input type = "checkbox" name = "Sina" value = "Sina">
Sina
<Input type = "checkbox" name = "Sohu" value = "Sohu">
Sohu
<Input type = "checkbox" name = "goyoyo" value = "goyoyo">
Goyoyo </TD>
</Tr>
<Tr>
<TD Height = "2" colspan = "2">
<Div align = "right">
<Input type = "Submit" name = "Submit" value = "let's get started" class = "test1">
</Div>
</TD>
</Tr>
</Table>
</Form>
</TD>
</Tr>
<Tr bordercolor = "# ffffff">
<TD Height = "20"> Note: Because multiple search engines are used for retrieval, the system outputs a long time. Please wait... </TD>
</Tr>
<Tr bordercolor = "# ffffff">
<TD Height = "20">
<Div align = "center"> we recommend that you use IE 5.x 800*600 to access aspcn. COM (2000-2001)
<Font size = "2">? </Font> </div>
</TD>
</Tr>
</Table>
</Body>
</Html>
<! --
Page code Display end Data Processing code Display
-->
<% Else
Server. scripttimeout = 100 'set the script time. Because the system output takes a long time, you must modify the script code execution time.
Set HTTP = server. Createobject ("asphttp. Conn") 'link component
Keyword = request. Form ("keyword") 'gets the search keyword
If request. Form ("yeah") = "yeah" then "determine whether to use the Yeah Search Engine
HTTP. url = "http://search.163.com/cgi-bin/search/engine/search.fcgi? Key = "& keyword' process the search address
HTTP. requestmethod = "get" 'sets the Data Retrieval Method "Get, get data"
Response. Write HTTP. geturl' output search results
End if
'The following code can be found in the previous example.
'Use Yahoo
If request. Form ("yahoo") = "yahoo" then
HTTP. url = "http://google.yahoo.com/bin/query_gb? P = "& keyword
HTTP. requestmethod = "get"
Response. Write HTTP. geturl
End if
'Use Sohu
If request. Form ("Sohu") = "Sohu" then
HTTP. url
= "Http://search.sohu.com/cgi-bin/search_main.cgi? Txt_keyword = "& keyword &" & page_index = 0 &
Fuzzy = 0 & catagory = Main"
HTTP. requestmethod = "get"
Response. Write HTTP. geturl
End if
'Use goyoyo
If request. Form ("goyoyo") = "goyoyo" then
HTTP. url = "http://www.goyoyo.com.cn/gyy/query? DBS = guidedbs & code = GB & query = "& keyword
HTTP. requestmethod = "get"
Response. Write HTTP. geturl
End if
Set HTTP = nothing
End if
'Processing submitted data has ended.
%>

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.