Skip to content

Commit

Permalink
🐛 fixed the site name not find.
Browse files Browse the repository at this point in the history
  • Loading branch information
AirportR committed Jun 19, 2024
1 parent e9e7abf commit 4a105f7
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions utils/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4a105f7

Please sign in to comment.