Call the Watercress interface to obtain the book information according to the ISBN

Source: Internet
Author: User

String Apikey = "111111111111111111111111111111"; String Isbnurl = "http://api.douban.com/book/subject/isbn/"; public static void Main (string[] args) throws Exception {//requesturl = Isbnurl + Isbnno + "? apikey=" + Apikey;//eg:http ://api.douban.com/book/subject/isbn/9787111298854?apikey=111111111111111111114 ISBN isbnTest = new ISBN (); String Isbnno = "9787111298854"; String XML = Isbntest.fetchbookinfobyxml (Isbnno); SYSTEM.OUT.PRINTLN (XML); /** * Obtains data from the watercress according to the ISBN number. has applied for Apikey, up to 40 requests per minute, sufficient. * @param isbnno * @return * @throws ioexception * * Public String Fetchbookinfobyxml (string isbnno) throws IOException {St Ring Requesturl = Isbnurl + Isbnno + "? apikey=" + Apikey; URL url = new URL (requesturl); URLConnection conn = Url.openconnection (); InputStream is = Conn.getinputstream (); InputStreamReader ISR = new InputStreamReader (IS, "utf-8"); BufferedReader br = new BufferedReader (ISR); StringBuilder sb = new StringBuilder (); String line = null; while (line = Br.readline ()) = null) {sB.append (line); } br.close (); return sb.tostring (); }  

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.