Minecraft_java_server / search_engine.py
THEZYZSTUDIO's picture
Update search_engine.py
a71cc63 verified
raw
history blame
526 Bytes
from duckduckgo_search import DDGS
def search_web(query: str, max_results: int = 5) -> str:
try:
with DDGS() as ddgs:
results = list(ddgs.text(query, max_results=max_results))
if not results:
return "لا توجد نتائج بحث."
formatted = "\n".join([f"- {r['title']}: {r['href']}\n {r['body']}" for r in results])
return f"🔍 نتائج البحث لـ '{query}':\n{formatted}"
except Exception as e:
return f"خطأ في البحث: {str(e)}"