Google Web Search API return 403 ...

在這篇Why does Google Search return HTTP Error 403? 有說明關於Error 403的原因。

我就是因為這條吃了403 = =|||
We received automated requests, such as scraping and prefetching. Automated requests are prohibited; all requests must be made as a result of an end-user action.

API Key可以重新再登錄申請過就可以了,不過依照上面的限制,Web Search API的實用性就大打折扣了。原因不難理解,畢竟Google是靠廣告吃飯的。

要用Web Search API做Data mining難了...
Usually not a problem if you are just providing web users with a search box, but not helpful if you're trying to use Google to go data mining. I guess they don't want you to go data mining using their API.

另外,要模擬瀏覽器送出搜尋的話只需要在HTTP Request中增加"User-Agent"欄位,把Firefox的user-agent填上去就可以了。不過這種做法,速度沒有Web Search API快。