Using component Search in ASP

Source: Internet
Author: User
Tags html page php and


Microsoft's ASP (Active server Page) technology greatly facilitates access to the database on the network, and because the ASP differs from the CGI requirements (reducing the resource footprint of the server), and ASP with Windows NT, 2000 of the combination of ASP technology is widely used in today's internet, but do not know that you have carefully thought about it! In addition to leveraging ADO access to the database and the use of several other built-in components, ASP can not do anything else, compared to perl,php and other programs, the ASP's function looks very simple, and lack of functionality; but older than after all, he left a hand for everyone, that is ASP components ( About the concept of components, now a lot of, you can not be mistaken, through the development of components you can do other languages (such as php,perl,c++) can do everything, even in some ways more than, this article seeks to show you the ASP components of the powerful functions, However, because of the ASP component itself (use of unregistered components), may sometimes use will appear unstable state, however, this article is to show you something and provide a way to you, and not other, so the lack of place to ask for forgiveness!

Code thinking: Generally speaking, we submit a form to a search engine program, the search engine to get the data submitted and then processed, return the results; however, this kind of thing is actually to obtain a submitted variable, we can use another way to directly follow the connection of the search engine, For example, you can use Yeah's homepage to search for a keyword "xuankong", or you can use the following connection Http://search.163.com/cgi-bin/search/engine/search.fcgi?key=xuankong "To get the results, this article is to access this direct connection using ASP's HTTP components, get the data that was originally returned in the Web page, and then output."

If this component can implement multithreading (if you can get data to different engines at the same time, do not need a single access and then get results) and code further optimization and improvement, it will greatly save your time, let you search at the same time to return multiple engine results!

Note: In the results of the search, because some of the engine's class uses the relative connection, so invalid (these results you can actually handle, but the author is too lazy, so do not want to spend that effort), but all the Web site and the Web page connection is valid, this article provides the code is only suitable for testing, Not suitable for specific applications, if you need specific applications, you need to use the appropriate HTTP components, or if you are a master of the program can write their own multithreaded components, about the HTTP component code, You can see in www.chinaasp.com, want to get more ASP components please visit www.aspcn.com!

The following are program code:

Code Start:


<!--
Have any comments and suggestions please mail:pu.junjie@263.net,
This code uses the HTTP component simultaneously searches out several search engine's data, lets all search results display in one page, this article only provides one kind of thought and the Ponder
To show you the powerful features of ASP components!
Because this component is not registered components may have limited functionality, and because the search for several engines at the same time (search engine can be arbitrarily expanded, but will affect the speed of), so the system output data for a long time, please wait patiently
Before using this code, please go to the Http://www.serverobjects.com/comp/asphttp3.zip first, and then unzip to your system32 directory (Winnt or Win2000).
Register this component with Regsvr32 asphttp.dll, and then copy this file to the relevant IIS executable directory, using IE or Netscape to browse
-->
<%
' Determines whether the output page or process the data, thus calling the 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= "Ba Junjie" >
< META name= "Keywords" content= "ASP, Components, 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-wi dth:1px; border-right-width:1px; border-bottom-width:1px; BORDER-LEFT-WIDTH:1PX}
-->
</style >

< body bgcolor= "#FFFFFF" leftmargin= "0" topmargin= "0" marginwidth= "0" marginheight= "0" >
< table width= "75%" border= "1" align= "center" height= "" 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= "Imitation _gb2312" > Super Search Engine </font ></b ></div >
</td >
</tr >
< tr bordercolor= "#66CC99" >
< td height= > Please select the following search engine: (Please 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= ">"
< form method= "POST" action= "http.asp" >
< table width= "96%" border= "0" height= "align=" "Center" >
< tr >
< TD height= "ten" width= "31%" >
< div align= "right" > Please enter the keyword you want to search: </div >
</td >
< TD height= "ten" width= "69%" >
< input type= "text" name= "keyword" class= "Test" >
</td >
</tr >
< tr >
< TD height= "2" width= "31%" >
< div align= "right" > Please select the search engine you use: </div >
</td >
< TD height= "2" width= "69%" >
< 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= > Remarks: Because the use of multiple search engine retrieval, so the system output time is longer, please be patient ... ...</td >
</tr >
< tr bordercolor= "#FFFFFF" >
< td height= ">"
< div align= "center" > recommended to use IE 5.x 800*600 Access aspcn.com copyright reserved (2000-2001) < font size= "2" >?</font ></d IV >
</td >
</tr >
</table >
</body >
<!--
End of page code display
Data processing Code Display
-->
<%else
server.scripttimeout = 100 ' Set script time, because the system output time is longer so the script code execution time must be modified
Set http = Server.CreateObject ("asphttp.conn") ' Link component
Keyword=request.form ("keyword") ' Get search keywords
If Request.Form ("yeah") = "Yeah" then to determine whether to choose to use the Yeah search engine
http. URL = "http://search.163.com/cgi-bin/search/engine/search.fcgi?key="; &keyword ' Process search address
http. Requestmethod = "Get" ' sets the way to obtain data "get, obtain data"
Response.Write Http.geturl ' Output search results
End If
' For the following code, please refer to the instructions in the example above.
' 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
' Submit data processing end
% >




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.