Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:59:40+00:00 2026-06-07T05:59:40+00:00

How can I search within a specific website with PHP and the Google API?

  • 0

How can I search within a specific website with PHP and the Google API? When I search for a keyword, I want the result from website1.com AND website2.com AND website3.com. For example:

<input name="search" value="keyword"> 
<input name="as_site" value="site1.com"> 
<input name="as_site" value="site2.com">
<input name="as_site" value="site3.com">

The result should be returned from these three websites only.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:59:41+00:00Added an answer on June 7, 2026 at 5:59 am

    Note: The Google Web Search API has been officially deprecated as of November 1, 2010. It >will continue to work as per our deprecation policy, but the number of requests you may make >per day will be limited. Therefore, we encourage you to move to the new Custom Search API.

    According to your form and assuming that the keyword field is named keyword this sample code is assuming you have only one site to search you can customize it to include many.
    Assuming that the site input is named site

    // The request also includes the userip parameter which provides the end
    // user's IP address. Doing so will help distinguish this legitimate
    // server-side traffic from traffic which doesn't come from an end-user.
    $query = $_POST['keyword'];
    $site = $_POST['site'];
    $url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
        . "q={$query}+Site:{$site}&userip=USERS-IP-ADDRESS";
    
    // sendRequest
    // note how referer is set manually
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, /* Enter the URL of your site here */);
    $body = curl_exec($ch);
    curl_close($ch);
    
    // now, process the JSON string
    $json = json_decode($body);
    // now have some fun with the results...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I do a search of the iPhone filesystem from within an application? I
I want to write a php code that can search for multiple keywords separated
Can I remove a specific CSS class from all XYZ elements within an element
An active_resource based class: Contact.search(:email => ['bar@foo.com','foo@bar.com']) would produce this: ?email[]=bar@foo.com&email[]=foo@bar.com The specific API
I have a search form where user can search for products within their specified
How can I search for a file within a directory and its sub-directories in
Can search engines such as Google index JavaScript generated web pages? When you right
I want to make a search box, where you can search between records in
I want to search a string for a specific pattern. Do the regular expression
The Google App Engine has previously released a Search API, that allows you to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.