How to search in google by using jav开发者_如何学Ca code?
I would have told you to use one of their API. Unfortunatly, there does not seems to exist one for search. As a consequence, you'll have to use HtmlUnit to emulate a browser and go see their results (obviously, you can go the harder way and do some HTTP queries by yourself. But who would do that ?).
Unfortunately the SOAP API has been deprecated. But you can use the AJAX API for non-JavaScript purposes as well, see for example:
http://www.ajaxlines.com/ajax/stuff/article/using_google_is_ajax_search_api_with_java.php
Update Jul 3 2018: This link is now broken; some code from there can be found here: https://stackoverflow.com/a/1546475/55787, and I found a copy of the article here: https://blog.csdn.net/hgd250/article/details/5214702 Furthermore the orginial link to the AJAX API is now broken, too. It seems that this one is closest to the original meaning: https://developers.google.com/custom-search/json-api/v1/overview?csw=1
See also this StackOverflow question:
- google java api for google search
精彩评论