"JAVA" access to book information through the ISBN one key __java

Source: Internet
Author: User
Package API;

Import Java.util.Vector;

Import Javax.swing.JOptionPane;
Import Net.sf.json.JSONArray;

Import Net.sf.json.JSONObject; /** * @TODO Get book information * @author love to knock the code of the Sea * @return Book basic information collection * * public class Getbookinfo {public static vector<string& Gt
		GETBYISBN (String ISBN) {vector<string> book=null;
		String Publish,name,author,price;
			try {book=new vector<string> ();
			String result=httputil.sendget ("https://api.douban.com/v2/book/isbn/:" +ISBN, "Utf-8");
			Converts the return string to a JSON object Jsonobject json=jsonobject.fromobject (result);
			Get Publishing house Publish=json.get ("publisher"). ToString ();
			Get the title Name=json.get ("title"). ToString ();
			Get the author, because the obtained is an array, so to convert Jsonarray arrauthor=jsonarray.fromobject (json.get ("author"));
			Author=arrauthor.getstring (0). toString ();
			Get Prices Price=json.get ("price"). ToString ();
			Store the resulting information in the collection Book.add (Name);
			Book.add (Author);
			Book.add (price);
		Book.add (Publish); catch (Exception e) {Joptionpane.showmessagEdialog (NULL, "Network connection failure ...");
	return book;
 }
}


The main is the use of Watercress API interface:

Https://developers.douban.com/wiki/?title=book_v2

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.