0

Lately, I've been working on a page in html which is supposed to search Google. I have a search box and a button but I'm wondering what the most efficient way to get the results from Google and display them on my page. If anyone knows I'd be glad if they helped me out.

{EDIT}

This is just a little project I'm working on. To be more specific I'd like to make it where what is typed in the search box gets taken from www.google.com/search and then the results of the Google search are displayed below.

Prince
  • 3
  • 5
  • Are you interested in displaying the Google search results of YOUR page? For example, if I search Kittens, do you want the search to show the "Kittens" only on your site, or the "Kittens" all over the web? – Justin Dec 31 '14 at 18:11
  • 1
    Look for Google's API. – Shahar Dec 31 '14 at 18:12

2 Answers2

1

Answer & Demo

You can create a custom google search engine for your sites, follow the steps, then get the code and paste it in a div inside the body tag. Here is a JSFiddle with an example of this (site:stackoverflow.com).

You can then edit the way the engine looks in the look and feel tab in the edit search menu.

How to edit the looks of a custom search engine

Hope this helps, good luck! :)

Community
  • 1
  • 1
undefined
  • 3,949
  • 4
  • 26
  • 38
0

So you're saying you want an HTML page with a single input and a submit button.

When the user enters text into the input and then presses submit what would you like to happen?

I see two basic approaches.

  1. Pass the search string as a parameter in the URL so the next page can be made aware of it using javascript. then use xmlhttprequest to grab the data from google and do a document.write to render the information to the user: example
  2. Insert a Div with some id in the page and then use the submit's onclick attribute to initiate an AJAX call that gets the data from google and then inserts it into the div's innerHTML without the need for multiple pages.

[UPDATE}

after looking into this it seems that XMLHttpRequest will not work with google and that the API is the way to go. source

Community
  • 1
  • 1
Logic1
  • 1,806
  • 3
  • 26
  • 43