Limit the number of links returned

This commit is contained in:
iwumingz 2022-04-09 13:47:59 +08:00
parent a975053a85
commit bd737ff820

View File

@ -18,6 +18,8 @@ async def google_search(content: str) -> Dict[str, str]:
if p.parent.has_attr('href'): if p.parent.has_attr('href'):
result[p.text] = p.parent.attrs.get('href') result[p.text] = p.parent.attrs.get('href')
logger.info(f"Google | Searching | {result[p.text]}") logger.info(f"Google | Searching | {result[p.text]}")
if len(result) > 10:
break
return result return result
resp.raise_for_status() resp.raise_for_status()