Skip to content

fix: Improve compatibility of search result display #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,17 @@ def organize_search_results(search_results):
results = search_results['results']
formatted_results = []

formatted_results.append(f"Searched {len(results)} web pages:")

for index, result in enumerate(results):
title = result.get('title', '未知标题')
title = result.get('title', 'Unknown Title')
url = result.get('url', '#')
preview = result.get('preview', '无预览内容')
preview = result.get('preview', 'Unknown Preview')

from urllib.parse import urlparse
domain = urlparse(url).netloc

formatted_result = f"\r\n<details><summary>资料[{index}]: {title}</summary>\r\n{preview}\r\n\n[Link]({url})\r\n</details>"
formatted_result = f"{index + 1}. [{title} *from {domain}*]({url})\n - {preview}\n"
formatted_results.append(formatted_result)

return '\n\n'.join(formatted_results)
Expand Down