"Java" gets current stock information

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.