google search with "site:"

Sharky Forums


Results 1 to 2 of 2

Thread: google search with "site:"

  1. #1
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203

    google search with "site:"

    I'd like to include a search box that automatically appends "site:www.sun.com" for example to the query.

    The basic code is:
    Code:
          <form action="http://www.google.com/search" method=get>
            <input name=q size=40 value="">
            <input type=submit value="Search" name="submit">
          </form>
    I'm pretty sure I need another input tag, and I've tried things like:
    Code:
    <input type="hidden" name="site:" value="www.sun.com">
     or 
    <input type="hidden" name="+" value="www.sun.com">
     or
    <input type="hidden" name="" value="site:www.sun.com">
    but nothing has worked.

    In the end, the actual URL should be for the user input of "blade":
    http://www.google.com/search?q=blade+site%3Awww.sun.com

    The blade query comes through fine, but whenever I add the + manually, I get a %2B instead. And it gets tacked on as another query.

    Any suggestions?

    Open Source is free like a puppy is free.

    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.

    Understanding Evolution

  2. #2
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203
    I finally found it. The missing piece:
    Code:
    <input type=hidden name=as_sitesearch value="www.sun.com">

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •