From 8ad96fec3f913d0b084e69ebe7ab58151ea3fde6 Mon Sep 17 00:00:00 2001 From: Gary Fu Date: Thu, 28 Oct 2021 19:17:59 +0800 Subject: [PATCH] =?UTF-8?q?calibre-web=E7=9A=84=E8=B1=86=E7=93=A3api=20pro?= =?UTF-8?q?vider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- src/NewDouban.py | 4 ++++ tests/DoubanTest.py | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8a3bc19..68bce84 100644 --- a/README.md +++ b/README.md @@ -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`使用~~ diff --git a/src/NewDouban.py b/src/NewDouban.py index cbb31ae..b68b71c 100644 --- a/src/NewDouban.py +++ b/src/NewDouban.py @@ -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 diff --git a/tests/DoubanTest.py b/tests/DoubanTest.py index ae04dc9..ea6b102 100644 --- a/tests/DoubanTest.py +++ b/tests/DoubanTest.py @@ -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'))