Using the book's ISBN to get information about the books from Douban

Source: Internet
Author: User

When we get the barcode of the book, we can use WebResponse and HttpWebRequest to get the information of the book from Douban. Get the address of the book information:

"Http://api.douban.com/book/subject/isbn/plus the book's barcode, can be only numbers, can also be added in the middle"-"(not including quotes) such as: 978-7-115-18103-9.

Note that the returned data needs to be encoded using UTF-8, and if GB2312 is used, it will be garbled.

Add the following function to the project, call it in the appropriate place, and pass in the ISBN number to get information about the book.

public string Getbookinfo (string ISBN)
{
String url = "http://api.douban.com/book/subject/isbn/";
HttpWebRequest request = (HttpWebRequest) httpwebrequest.create (url + ISBN);
WebResponse response = Request. GetResponse ();
StreamReader reader = new StreamReader (response. GetResponseStream (), encoding.getencoding ("Utf-8"));
String BookInfo = reader. ReadToEnd ();
Reader. Close ();
Reader. Dispose ();
Response. Close ();
return BookInfo;

}

In the absence of application for Douban Apikey, only 10 times per minute, if the application can be reached 40 times.

To include Apikey, the URL at the time of the access is changed to:

Http://api.douban.com/book/subject/isbn/ISBN?APIKEY= your apikey  , which ISBN is the ISBN, finally your apikey need to replace your number.

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.