Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 修复专栏文字内容解析失败的问题 #229

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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