From 4a105f7caec20c04835fa38a11a2ce7a4588d4b1 Mon Sep 17 00:00:00 2001 From: AirportR Date: Wed, 19 Jun 2024 11:53:15 +0800 Subject: [PATCH] :bug: fixed the site name not find. --- utils/collector.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/utils/collector.py b/utils/collector.py index 38fc20c..dc25076 100644 --- a/utils/collector.py +++ b/utils/collector.py @@ -364,18 +364,15 @@ async def fetch_title(s: aiohttp.ClientSession, url): else: domain2 = '' async with aiohttp.ClientSession(headers=_headers) as session: - tasks = [] if domain: url_domain = f"{parsed_url.scheme}://{domain}" - tasks.append(fetch_title(session, url_domain)) - if domain2: + domain_title = await fetch_title(session, url_domain) + + if not domain_title: url_subdomain = f"{parsed_url.scheme}://{domain2}" - tasks.append(fetch_title(session, url_subdomain)) + await fetch_title(session, url_subdomain) - results = await asyncio.gather(*tasks) - domain_title = results[0] if len(results) > 0 else "" - domain_title2 = results[1] if len(results) > 1 else "" - site_title = domain_title or domain_title2 or "" + site_title = domain_title or "" return site_title @logger.catch()