开发者

Using Java to automate google and print output

Does anyone know if there's an ea开发者_如何学Pythonsy way to implement this:

I have an array of strings (~650 elements) and would like to google each element, and then have the number of results acquired in each search stored in another integer array. I looked at the Google API, but it seems a little daunting to me, it seems like a fairly simple task, but can't seem to find any guidance on how to do this.

Help is much appreciated. Thanks.


My first thought was to do the following. I don't think its the fastest or most elegant way, but I think it should do the trick:

If you check a URL on Google, they all look the same:

http://www.google.com/search?q='here your searchword'

So i would just iterate over your array and for each string create a url like e.g.

http://www.google.com/search?q=test

do a HTTP-Post for that and parse the result.

Here is a short example of the HTTPPost. You can also see how to get the response. I don't know how googles response is looking, but if you just print out the whole response, I think you will see how you have to parse it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜