I was trying to do something similar - I wanted to query a domain in Google and return the number of links that existed to a site so I could analyse link popularity between multiple sites, but for some reason Google spits out an error.
My same script works with MSN, Excite, AlltheWeb, Yahoo and more, but Google is being a pain 🙂
Had a mate who is a bit of a guru look at the problem and he couldnt understand why it wouldnt return the correct result either...
I ended up using Yahoo - as Google is the fall through result. Not as accurate - but better than nothing.