Skip to content

Commit 8afa814

Browse files
committed
修复api失效问题
1 parent 143bdca commit 8afa814

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

sagiri_bot/handler/handlers/pdf_searcher.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ async def pdf_searcher(app: Ariadne, message: MessageChain, group: Group, keywor
4747
async with session.get(url=url, proxy=proxy) as resp:
4848
html = await resp.read()
4949
soup = BeautifulSoup(html, "html.parser")
50-
divs = soup.find(
51-
"div", {"id": "searchResultBox"}
52-
).find_all(
53-
"div", {"class": "resItemBox resItemBoxBooks exactMatch"}
54-
)
50+
try:
51+
divs = soup.find(
52+
"div", {"id": "searchResultBox"}
53+
).find_all(
54+
"div", {"class": "resItemBox resItemBoxBooks exactMatch"}
55+
)
56+
except AttributeError:
57+
await app.sendGroupMessage(group, MessageChain(f"请检查{base_url}是否可以正常访问!若不可以请检查代理是否正常,若代理正常可能为域名更换,请向仓库提出PR"))
58+
return
5559
count = 0
5660
books = []
5761
text = "搜索到以下结果:\n\n"

0 commit comments

Comments
 (0)