From 595132aa9f210fb3f264cb9baa5ea4e8d8d889eb Mon Sep 17 00:00:00 2001 From: AirportR Date: Wed, 19 Jun 2024 11:58:57 +0800 Subject: [PATCH] :bug: fixed the site name not find. --- botmodule/subinfo.py | 3 ++- utils/collector.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/botmodule/subinfo.py b/botmodule/subinfo.py index a716baa..aa3ebb0 100644 --- a/botmodule/subinfo.py +++ b/botmodule/subinfo.py @@ -77,7 +77,8 @@ async def getSubInfo(_, message): subinfo_text = f"☁️订阅名称:{subname}" + subinfo_text else: subinfo_text = f"☁️订阅链接:{url}" + subinfo_text - subinfo_text = f"✈️机场名:{site_name}\n" + subinfo_text if site_name else "未知" + site_name = f"✈️机场名:{site_name}\n" if site_name else "✈️机场名:未知\n" + subinfo_text = site_name + subinfo_text await back_message.edit_text(subinfo_text, parse_mode=ParseMode.DISABLED) except RPCError as r: logger.error(str(r)) diff --git a/utils/collector.py b/utils/collector.py index dc25076..3401329 100644 --- a/utils/collector.py +++ b/utils/collector.py @@ -366,11 +366,13 @@ async def fetch_title(s: aiohttp.ClientSession, url): async with aiohttp.ClientSession(headers=_headers) as session: if domain: url_domain = f"{parsed_url.scheme}://{domain}" + logger.info(f'获取域名的站点标题: {url_domain}') domain_title = await fetch_title(session, url_domain) - if not domain_title: + if not domain_title and domain2: url_subdomain = f"{parsed_url.scheme}://{domain2}" - await fetch_title(session, url_subdomain) + logger.info(f'尝试获取二级域名站点标题: {url_subdomain}') + domain_title = await fetch_title(session, url_subdomain) site_title = domain_title or "" return site_title