Using Google is AJAX Search API with Java ...
http://www.ajaxlines.com/ajax/stuff/article/using_google_is_ajax_search_api_with_java.php
I was rather depressed over a year ago when Google deprecated their SOAP Search API with their AJAX Search API. Essentially Google was saying that they didn want anyone programmatically accessing Google search results unless they were going to be presenting the results unaltered in a rectangular portion of a website. This was particularly troubling to me because, like many academics, I have relied on the API to do automated queries, especially for Warrick.
A few months ago I got a little excited when Google opened their AJAX API to non-JavaScript environments. Google is now allowing queries using a REST-based interface that returns search results using JSON. The purpose of this API is still to show unaltered results to your website is user, but I don see anything in the Terms of Use that prevent the API being used in an automated fashion (having a program regularly execute queries), especially for research purposes, as long as you aren trying to make money (or prevent Google from making money) from the operation.
So, here is what I have learned about using the Google AJAX Search API with Java. I haven found this information anywhere else on the Web in one spot, so I hope you will find it useful.
Here is a Java program that queries Google three times. The first query is for the title of this blog (Questio Verum). The second query asks Google if the root page has been indexed, and the third query asks how many pages from this website are indexed. (Please forgive the poor formatting... Blogger thinks it knows better than I how I want my text indented. Argh.)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import org.json.JSONArray; // JSON library from http://www.json.org/java/
import org.json.JSONObject;
public class GoogleQuery {
// Put your website here
private
Ïà¹ØÎĵµ£º
DOM³õ²½
DOMÊÇDocument Object ModelµÄËõд£¬¼´Îĵµ¶ÔÏóÄ£ÐÍ¡£Ç°Ãæ˵¹ý£¬XML½«Êý¾Ý×é֯Ϊһ¿ÅÊ÷£¬ËùÒÔDOM¾ÍÊǶÔÕâ¿ÅÊ÷µÄÒ»¸ö¶ÔÏóÃèÐð¡£Í¨Ë×µÄ˵£¬¾ÍÊÇͨ¹ý½âÎöXMLÎĵµ£¬ÎªXMLÎĵµÔÚÂß¼ÉϽ¨Á¢Ò»¸öÊ÷Ä£ÐÍ£¬Ê÷µÄ½ÚµãÊÇÒ»¸ö¸ö¶ÔÏó¡£ÎÒÃÇͨ¹ý´æÈ¡ÕâЩ¶ÔÏó¾ÍÄܹ»´æÈ¡XMLÎĵµµÄÄÚÈÝ¡£
ÏÂÃæÎÒÃÇÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£¬¿´¿´ÔÚDOMÖ ......
JavaÁ¬½Ó³Ø BoneCP 0.6.0 ·¢²¼
ÎÒÒª·¢²¼ÐÂÎÅ ÊղشËƪÐÂÎÅ ºìÊí ·¢²¼ÓÚ£º 2009Äê12ÔÂ28ÈÕ (6ÆÀ)
BoneCP ÊÇÒ»¸ö¿ªÔ´µÄ¿ìËÙµÄ JDBC Á¬½Ó³Ø¡£
0.6.0 °æ±¾µÄ¸Ä½øÄÚÈÝ°üÀ¨£º
1. Ôö¼Óͨ¹ý getAsyncConnection ·½·¨»ñÈ¡Òì²½Á¬½ÓµÄ¹¦ÄÜ
2. Ôö¼ÓÁËÊý¾Ý¿âÁ¬½ÓµÄ»Øµ÷¹³×Ó
3. Ôö¼ÓÁËÓÃÒÔÏòÊ״λñÈ¡µÄÁ¬½Ó·¢ËÍÒ»¸öÌض¨µÄÓï¾äµÄ¹¦Ä ......
Ò»¡¢Ê¹ä¯ÀÀÆ÷²»»º´æÒ³ÃæµÄ¹ýÂËÆ÷
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* ÓÃÓÚµÄʹ Browser ²» ......
javaÈçºÎ»ñµÃ´æ´¢¹ý³ÌµÄ²ÎÊý(Àý×Ó)
Connection conn = JDBCUtils.getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getProcedureColumns(null, " ......
1£®Servlet³ÌÐòµÄÈë¿ÚµãÊÇ£º£¨ £©
A init£¨£©
B main£¨£©
C service£¨£©
D doGet£¨£©
²Î¿¼´ð°¸£ºA
2. SeverletÖУ¬HttpSeverletResponseµÄʲô·½·¨ÓÃÀ´°ÑÒ»¸öHTTPÇëÇóÖض¨Ïòµ½ÁíÍâµÄURL£¿£¨ £©
A sendURL()
B redirectURL()
C sendRedirect()
D ......