views:

262

answers:

7

I want to call a google service using javascript with a keyword and a website url, and get from google the position of this site while searching with this keyword.

This is possible? can be done just using javascript or will need a server side language?

+1  A: 

This link looks promising: Getting google page rank using javascript

Kevin Pullin
A: 

You can use the Google Search API to develop any search from applications or pages in AJAX

backslash17
A: 

Not exactly what you want, but Google Webmaster Tools will list top searches for your site and how far down the results you are.

Joe Beda
+1  A: 

You're going to have security issues using JavaScript to query another domain that isn't the one that served the HTML.

If you can write your own service, your best bet (for scraping) would be to send a query to this page: http://www.google.com/ie. It provides clean HTML that can be parsed with a regular expression. This page is also nice in that you can pass in a 'num' parameter and get more than just 10 results at a time. (if you're looking for perfect results, when doing this you aren't going to get exactly the same results as going 10 at a time).

With a service like this running on your server, your JavaScript code won't have any problems, until Google notices too many queries coming from your server's IP address and decides to blacklist you. ;)

I'd also suggest using Google's AJAX Search API, if you can live with it being limited to 64 total results.

great_llama
A: 

You can just use curl and regexp to get the results but Google will catch on to you scraping results if you do a lot of calls (and return bogus results) so you have to have full header support.

A: 

The 1st link given by Kevin Pullin, indeed works. You can get what you want to with SEO Analyzer Download from code.google.com/p/seoanalyzer

+1  A: 

You can use my PHP Class, it searches via Google AJAX Search API and checks the results for your Domain/URL. You can also check for different Domains/URLs if you want to know the ranking for your competitors:

http://bohuco.net/blog/2010/07/google-ranking-checker-class-in-php/

DerFichtl