Coder Social home page Coder Social logo

bookmeet_backend's Introduction

bookMeet_backend

简介

通过Node.js的puppeteer库爬取并解析相关数据,以JSON的格式传递给前端

支持的数据源

数据源 url
豆瓣新书速递 /douban
豆瓣搜索书目 /search
豆瓣获取书籍标签 /getTags
当当新书热卖榜 /dangdang
超星图书好书榜 /chaoxing
中图网图书畅销榜 /booksChina

支持的参数

类型 (c)

数据源 url
豆瓣新书速递 - 文学 /douban?c=literature
豆瓣新书速递 - 小说 /douban?c=novel
豆瓣新书速递 - 科学新知 /douban?c=science

搜索内容 (q)

“豆瓣搜索书目”适用

数量 (n)

所有源皆适用

书籍id (id),请求id (idd)

“豆瓣获取书籍标签”适用(适配原始前端请求)

例子

  • 获取中图网图书畅销榜的前5本:/booksChina?n=5

  • 获取豆瓣新书速递 - 文学的前10本:/douban?c=literature&n=10 或 /douban?n=10&c=literature

  • 豆瓣搜索“朝花夕拾”:/search?q=朝花夕拾

  • 查询书籍id为33420947(三体全集),请求id为1的标签:/getTags?id=33420947&idd=1

数据格式

返回JSON格式数据,例:

{
  "category": "douban",
  "time": 1643520838436,
  "data": [
    {
      "name": "宋代**的改革:王安石及其新政",
      "author": "刘子健",
      "img": "https://img1.doubanio.com/view/subject/s/public/s34062348.jpg",
      "rate": 8.3,
      "url": "https://book.douban.com/subject/35653740/"
    }
  ]
}

其中,

  • "category" - String类型,表示数据源
  • "time" - Number类型,表示数据最后爬取的时间
  • "data" - Array类型,每个元素包含一本书的信息,用JSON储存,其中
    • "name" - String类型,书名
    • "author" - String类型,作者
    • "img" - String类型,封面图片
    • "rate" - Number类型,满分10分的用户评分
    • "url" - String类型,书本在相关数据源的链接

特别地,“豆瓣获取书籍标签”返回的数据格式与其余源有些许差别,例:

{
  "category": "getTags",
  "time": 1656998613649,
  "data": [
    "反乌托邦",
    "乔治·奥威尔",
    "政治寓言",
    "政治",
    "1984",
    "外国文学"
  ],
  "id": 1
}

其中,

  • "category", "time" - 同上
  • "data" - Array类型,每个元素包含一个String类型标签
  • "id" - Number类型,请求时携带的请求id

错误处理

当请求发生错误时,返回空数据,例:

{
  "category": "search",
  "time": "-1",
  "data": []
}

其中,

  • "category" - String类型,表示数据源
  • "time" - Number类型,-1表示请求发生错误
  • "data" - Array类型,空数组

特别地,当”豆瓣获取书籍标签“发生错误时,会额外返回"id"属性,值为传入的"idd"参数

bookmeet_backend's People

Contributors

dependabot[bot] avatar xiakele avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.