`
feohoo
  • 浏览: 109832 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

利用图书的ISBN从豆瓣网获取图书的信息 .

阅读更多

当我们获取了图书的条码后,可以使用WebResponse 和HttpWebRequest从豆瓣网获取图书的信息.获取图书信息的地址:

"http://api.douban.com/book/subject/isbn/   加上图书的条码,可以是只有数字,也可以在中间加入"-"(不包括引号)如:978-7-115-18103-9.

注意,返回的数据需要使用UTF-8编码,如果使用GB2312,将会是乱码.

将下面的函数加入工程,在适当的地方调用,传入ISBN号,即可获取图书相关的信息.

        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;

        }

在没有申请豆瓣网的APIKEY时,每分钟只能调用10次,如果申请了可以达到40次.

若要包含APIKEY,则在访问时的URL改为:

http://api.douban.com/book/subject/isbn/ISBN?APIKEY=你的APIKEY   ,其中的ISBN即书号,最后你的APIKEY需要替换成你的号码.

 

 

查询例子:

http://api.douban.com/book/subject/isbn/978-7-115-18103-9

 

查询出来的结果: 
 <?xml version="1.0" encoding="UTF-8" ?>
- <entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
  <id>http://api.douban.com/book/subject/3171438</id>
  <title>数控加工与编程</title>
  <category scheme="http://www.douban.com/2007#kind" term="http://www.douban.com/2007#book" />
- <author>
  <name>顾晔 编</name>
  </author>
  <link href="http://api.douban.com/book/subject/3171438" rel="self" />
  <link href="http://book.douban.com/subject/3171438/" rel="alternate" />
  <link href="http://img1.douban.com/spic/s5924224.jpg" rel="image" />
  <link href="http://m.douban.com/book/subject/3171438/" rel="mobile" />
  <summary>《高职高专机电类规划教材•数控加工与编程》以Fanuc 0i系统为蓝本,深入浅出地讲述了数控车床、加工中心的基本理论知识及其编程方法。书中所有程序中的每行语句后都附有详细、清晰的注释说明,所有程序都在数控机床上实际运行过。《高职高专机电类规划教材•数控加工与编程》各章设有思考与练习,便于学生更好地掌握所学内容,并附有Fanuc 0i系统、华中数控系统常用指令表及说明,供读者查阅和学习。</summary>
  <db:attribute name="isbn10">7115181039</db:attribute>
  <db:attribute name="isbn13">9787115181039</db:attribute>
  <db:attribute name="title">数控加工与编程</db:attribute>
  <db:attribute name="pages">213</db:attribute>
  <db:attribute name="author">顾晔 编</db:attribute>
  <db:attribute name="price">24.00元</db:attribute>
  <db:attribute name="pubdate">2008-9</db:attribute>
  <gd:rating average="0" max="10" min="0" numRaters="0" />
  </entry>
中图法目录查询:
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics