Import Java.io.bufferedreader;import Java.io.inputstreamreader;import Java.net.httpurlconnection;import Java.net.url;public class Mainprocess {public static string Gethtmlconentbyurl (String ssourl) {try{url url = new URL (ssour L); HttpURLConnection con = (httpurlconnection) url.openconnection (); con.setinstancefollowredirects (false); Con.setusecaches (false); Con.setallowuserinteraction (false); Con.connect (); StringBuffer sb = new StringBuffer (); String line = ""; BufferedReader urlinput = new BufferedReader (New InputStreamReader (Con.getinputstream ())); Urlinput.readline ()) = null) {sb.append (line);} Con.disconnect (); return sb.tostring (). toLowerCase ();} catch (Exception e) {return null;}} public static void Main (string[] args) {string[] ind = {"Stock name", "Open Today", "Yesterday Close", "Current Price", "Today's highest price", "Today's lowest price", "buy a quote", "sell an offer", " Number of transactions "," Transaction Amount "," buy a Share "," buy a quote "," buy two Shares "," buy two quotes "," buy three Shares "," buy three quotes "," buy four Shares "," buy four quotes "," buy five Shares "," buy five quotes "," sell one share "," sell a Quote "," sell two shares "," sell two quote " , "sell three shares", "sell three quotes", "sell four Shares", "sell four quotes", "sell five Shares", "sell five quotes", "Current date", "Current Time"}; String SS = GEThtmlconentbyurl ("http://hq.sinajs.cn/list=sh600066");//The page you want to access string[] FCS = Ss.split ("\" ");//press" number split character string SCS = FCS[1]; string[] TCS = Scs.split (",");//press, number split character for (int i=0;i<tcs.length-1;i++) System.out.println (Ind[i] + ":" +tcs[i]);}}
"Java" gets current stock information