🐛 修复描述为空时无法解析

This commit is contained in:
xtaodada 2022-10-03 18:50:56 +08:00
parent 1da600f9d7
commit 44351ac7a1
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -70,7 +70,10 @@ async def get_loft(url: str) -> List[LofterItem]:
res = await request.get(url)
assert res.status_code == 200
username, avatar, name, bio, soup = parse_loft_user(url, res.text)
try:
title = soup.findAll("div", {"class": "text"})[-1].getText().strip()
except IndexError:
title = ""
links = soup.findAll("a", {"class": "imgclasstag"})
audio_link = None
audio = soup.find("div", {"class": "img"})