views:

18

answers:

1

I have a textbox and a button in my page. On giving something in the textbox and pressing the button it should go to the google server and collect all search result. How to do that?

I can use Google AJAX Search API but can't i do these things without using the api?

+1  A: 

You can establish a TCP connection on port 80, and then manually create the GET request for the google search. You will then need to parse the resulting html to extract the search results.

Have a look at RFC 2616 for more information.

--

Dev, I don't know what programming language you are using, so it's hard for me to give an example, however the concept is easily demonstrated using a telnet client. You can use telnet to connect to google on port 80.

telnet www.google.com 80

From here, you can type your requests. If we do a quick google search in your browser for something and then check the URL, we see something along the lines of

http://www.google.com/search?q=stack+overflow

This gives us the general form of the search request, and from this template, we can construct any search query simply by replacing "stack+overflow" with our desired query. So back in the telnet client, we can type a GET request, after connecting, by typing

GET http://www.google.com/search?q=stack+overflow HTTP/1.0 and then pressing enter twice, to signify the end of the GET request, as double newlines indicate the end of the request. There are a lot of various options for GET requests, which will vary depending on your needs. These options are detailed in the RFC.

After you press enter twice, you should see html. This is the html of the google search results page that would normally be rendered in your web browser.

Hope this helps.

Jim
any demo or example?
Dev