Skip to content

Commit

Permalink
:bugs: 修复专栏文字内容解析失败的问题 (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
Well2333 authored Jul 8, 2024
1 parent d8e6a16 commit ebb8ed8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions nonebot_plugin_bilichat/content/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ async def from_id(cls, bili_number: str, options: Options | None = None):
cv = cv.text
http_parser: _Element = etree.fromstring(cv, etree.HTMLParser(encoding="utf-8"))
cv_title: str = http_parser.xpath('//h1[@class="title"]/text()')[0]
main_article: _Element = http_parser.xpath('//div[@id="read-article-holder"]')[0]
plist: _ElementUnicodeResult = main_article.xpath(XPATH)
cv_text = [text.strip() for text in plist if text.strip()]
try:
main_article: _Element = http_parser.xpath('//div[@id="read-article-holder"]')[0]
plist: _ElementUnicodeResult = main_article.xpath(XPATH)
cv_text = [text.strip() for text in plist if text.strip()]
except Exception:
logger.warning(f"专栏 cv{cvid} 文字内容解析失败,可能是专栏格式不受支持或未包含文字内容。")
cv_text = ["专栏文字内容解析失败,可能是专栏格式不受支持或未包含文字内容。"]
b23_url = await get_b23_url(f"https://www.bilibili.com/read/cv{cvid}")
except AbortError:
raise
Expand Down

0 comments on commit ebb8ed8

Please sign in to comment.