To read the article online, visit http://www.4GuysFromRolla.com/webtech/060699-1.shtml

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.

  • /four_guys/article_four/web_search.asp" target="other">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.

    
    <center>
    <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>
     </select>
    
     <input type="text" name="txtSearchWords" size="30">
    
     <input type="submit" name="btnSearch" value="Search">
    </form>
    </center>
    

    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=" & _
                         Request.Form("txtSearchWords"))
    End If
    

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

    In /four_guys/article_four/web_search.asp" target="other">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!

    Enjoy!

    Christopher Miller
    Kyrakin@excite.com


    Attachments:

  • Viewe the code for web_search.asp (text format)
  • /four_guys/article_four/web_search.asp" target="other">View this script in action!


  • Article Information
    Article Title: Search the Internet from your site!
    Article Author: Christopher Miller
    Published Date: Sunday, June 06, 1999
    Article URL: http://www.4GuysFromRolla.com/webtech/060699-1.shtml


    Copyright 2017 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers