calibre-web的豆瓣api provider
This commit is contained in:
parent
3a36b17b0b
commit
8ad96fec3f
|
@ -12,9 +12,9 @@
|
|||
|
||||
### 使用方法(已废弃)
|
||||
|
||||
修改`src/douban.py`中的`doubanUrl`地址后,复制`src/douban.py`到`calibre-web/cps/metadata_provider/`目录下,重启项目。
|
||||
~~修改`src/douban.py`中的`doubanUrl`地址后,复制`src/douban.py`到`calibre-web/cps/metadata_provider/`目录下,重启项目。~~
|
||||
|
||||
**注意:由于豆瓣api已经不开放使用了,这个豆瓣api需要连接`simple-boot-douban-api`使用**
|
||||
~~由于豆瓣api已经不开放使用了,这个豆瓣api需要连接`simple-boot-douban-api`使用~~
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import re
|
||||
import time
|
||||
|
||||
import requests
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from urllib.parse import urlparse, unquote
|
||||
|
@ -78,8 +80,10 @@ class DoubanBookLoader:
|
|||
@lru_cache(maxsize=DOUBAN_BOOK_CACHE_SIZE)
|
||||
def load_book(self, url):
|
||||
book = None
|
||||
start_time = time.time()
|
||||
res = requests.get(url, headers=DEFAULT_HEADERS)
|
||||
if res.status_code in [200, 201]:
|
||||
print("下载书籍:{}成功,耗时{:.0f}ms".format(url, (time.time() - start_time) * 1000))
|
||||
book_detail_content = res.content
|
||||
book = self.book_parser.parse_book(url, book_detail_content.decode("utf8"))
|
||||
return book
|
||||
|
|
|
@ -3,7 +3,5 @@ from douban import Douban
|
|||
if __name__ == "__main__":
|
||||
douban = Douban()
|
||||
result = douban.search('人民的名义')
|
||||
result = douban.search('人民的名义')
|
||||
result = douban.search('人民的名义')
|
||||
for book in result:
|
||||
print(book.get('title'), book.get('url'))
|
||||
|
|
Loading…
Reference in New Issue