Using HTTP components to implement multiple engine search function

Source: Internet
Author: User
Tags html page implement php and query
Icrosoft'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 obtain the submitted data 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 to access the search engine, for example, you can use
Yeah's homepage searches for a keyword "xuankong", or you can use the following connection "http://search.163.com/cgi-
Bin/search/engine/search.fcgi?key=xuankong "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!

Code Start:
$#@60;! --
Have any comments and suggestions please mail:pu.junjie@263.net,
This code uses the HTTP component with the castrate 鞒 June thought Father Netural castrated gourmands  the ne  荩 the  union  The weapon is the castrated Uighur the horse to be allowed the Colt Boaster Huan Flounder while Xian our school  guilt make Emperor ┮, a few  to return to stir the worm, so 続 SP components powerful function! Because this component is not registered components may have limited functionality, and because the search for several engines simultaneously (search engine can be arbitrarily expanded, but will affect the speed of), so the system output data for a long time, please be patient before using this code please you first to download
Http://www.serverobjects.com/comp/asphttp3.zip, well 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
--$#@62;
$#@60;%
' 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
%$#@62;
$#@60;! --
HTML page Code display
--$#@62;
$#@60;html$#@62;
$#@60;head$#@62;
$#@60;title$#@62; Aspcn.com Super search engine $#@60;/title$#@62;
$#@60;meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "$#@62;
$#@60; META name= "Author" content= "Ba Junjie" $#@62;
$#@60; META name= "Keywords" content= "ASP, Component, www.aspcn.com" $#@62;
$#@60;style type= "Text/css" $#@62;
$#@60;! --
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}
--$#@62;
$#@60;/style$#@62;
$#@60;/head$#@62;
$#@60;body bgcolor= "#FFFFFF" leftmargin= "0" topmargin= "0" marginwidth= "0" marginheight= "0" $#@62;
$#@60;table width= "75%" border= "1" align= "center" height= "0"
cellspacing= "1" bgcolor= "#66CC99" bordercolor= "#FFFFFF" $#@62;
$#@60;tr$#@62;
$#@60;TD height= "4" $#@62;
$#@60;div align= "center" $#@62;$#@60;font color= "#000000" size= "2"
Face= "Arial" $#@62; Aspcn.com$#@60;/font$#@62;$#@60;font color= "#000000" size= "3"
face= "Arial" $#@62;$#@60;/font$#@62;$#@60;b$#@62;$#@60;font color= "#000000" size= "3" face= "Arial" $#@62;
$#@60;/font$#@62;$#@60;font color= "#000000" size= "3" face= "Imitation _gb2312" $#@62; Super search engine
$#@60;/font$#@62;$#@60;/b$#@62;$#@60;/div$#@62;
$#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;tr bordercolor= "#66CC99" $#@62;
$#@60;TD height= "21" $#@62; Please select the following search engine: (Please note: This search engine is only suitable for $#@60;font
Color= "#ffffff" $#@62; web search $#@60;/font$#@62;) $#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;tr bordercolor= "#FFFFFF" align= "center" valign= "Top" $#@62;
$#@60;TD height= "20" $#@62;
$#@60;form method= "POST" action= "http.asp" $#@62;
$#@60;table width= "96%" border= "0" height= "" align= "center" $#@62;
$#@60;tr$#@62;
$#@60;TD height= "Ten" width= "31%" $#@62;
$#@60;div align= "Right" $#@62, please enter the keyword you want to search: $#@60;/div$#@62;
$#@60;/td$#@62;
$#@60;TD height= "Ten" width= "69%" $#@62;
$#@60;input type= "text" name= "keyword" class= "test" $#@62;
$#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;tr$#@62;
$#@60;TD height= "2" width= "31%" $#@62;
$#@60;div align= "Right" $#@62, please select the search engine you use: $#@60;/div$#@62;
$#@60;/td$#@62;
$#@60;TD height= "2" width= "69%" $#@62;
$#@60;input type= "checkbox" Name= "Yeah" value= "Yeah" $#@62;
Yeah
$#@60;input type= "checkbox" Name= "yahoo" value= "Yahoo" $#@62;
Yahoo
$#@60;input type= "checkbox" Name= "Sina" value= "Sina" $#@62;
Sina
$#@60;input type= "checkbox" Name= "Sohu" value= "Sohu" $#@62;
Sohu
$#@60;input type= "checkbox" Name= "Goyoyo" value= "Goyoyo" $#@62;
goyoyo$#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;tr$#@62;
$#@60;TD height= "2" colspan= "2" $#@62;
$#@60;div align= "right" $#@62;
$#@60;input type= "Submit" name= "Submit" value= "Let's Get Started" class= "Test1" $#@62;
$#@60;/div$#@62;
$#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;/table$#@62;
$#@60;/form$#@62;
$#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;tr bordercolor= "#FFFFFF" $#@62;
$#@60;TD height= "20" $#@62 Note: Due to the use of multiple search engine retrieval, so the system output time is longer, please be patient
Stay $#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;tr bordercolor= "#FFFFFF" $#@62;
$#@60;TD height= "20" $#@62;
$#@60;div align= "center" $#@62; it is recommended to use IE 5.x 800*600 Access aspcn.com Copyright Reservation (2000-2001)
$#@60;font size= "2" $#@62;©$#@60;/font$#@62;$#@60;/div$#@62;
$#@60;/td$#@62;
$#@60;/tr$#@62;
$#@60;/table$#@62;
$#@60;/body$#@62;
$#@60;/html$#@62;
$#@60;! --
Page code display end data processing code display
--$#@62;
$#@60;%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 processing 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
%$#@62;



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.