When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Sunday, June 06, 1999

Search the Internet from your site!
By Christopher Miller

A quick and easy way to add interactivity to your site is to allow your visitors to search the Internet. You can add any search engine to your site as long as they use a query string, here's how.

- continued -

  • Click here for an example

    The first thing you want to do is go to your favorite search engines and grab their query string. You can grab it by simply doping a search. Below is a list of the major search engines and the query strings they use:

    Yahoo: http://search.yahoo.com/bin/search?p=SEARCHWORDS
    AltaVista: http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&q=SEARCHWORDS
    Excite: http://search.excite.com/search.gw?search=SEARCHWORDS&Submit=Search
    Hotbot: http://www.hotbot.com/?MT=SEARCHWORDS&SM=MC&DV=0&LG=any&DC=10&DE=2&clickSrc=search&_v=2&OPs=MDRTP
    Lycos: http://www.lycos.com/cgi-bin/pursuit?cat=dir&query=SEARCHWORDS
    MSN: http://search.msn.com/results.asp?RS=CHECKED&UN=doc&CO=20&Form=MSNH&MT=SEARCHWORDS
    Webcrawler: http://www.webcrawler.com/cgi-bin/WebQuery?searchText=SEARCHWORDS
    Go: http://www.go.com/Titles?qt=SEARCHWORDS&col=WW&sv=IS&lk=noframes&svx=home_searchbox

    The next thing you want to do is to create your page. Lets start with a simple form, a select box, text box, and submit button. The select box will be used for the search engines, and the text box will be used for the search words.

    <form action="web_search.asp" method="post">
     <select name="selEngines">
      <option value="yahoo">Yahoo</option>
      <option value="altavista">Alta Vista</option>
      <option value="excite">Excite</option>
      <option value="hotbot">Hotbot</option>
      <option value="lycos">Lycos</option>
      <option value="msn">MSN</option>
      <option value="webcrawler">Webcrawler</option>
      <option value="go">Go</option>
     <input type="text" name="txtSearchWords" size="30">
     <input type="submit" name="btnSearch" value="Search">

    When I listed the search engines' querystrings, notice how I marked the "SEARCHWORDS" in blue. This is where we want to place the input from our text box strSearchWords. All you need to do is create a simple If...Then statement with a Response.Redirect that goes to the correct search engine, like I've shown below:

    If Request.Form("selEngines") = "yahoo" Then
       Response.Redirect("http://search.yahoo.com/bin/search?p=" & _
    End If

    Do this for all of the search engines and your all done! (See the code for web_search.asp.)

    In the example I also show you how to achieve the same result with radio buttons. You can even go a step further and do check boxes that will allow you to search multiple engines opening a new window for each one!


    Christopher Miller


  • Viewe the code for web_search.asp (text format)
  • View this script in action!

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article