web search p1
This commit is contained in:
@@ -1,14 +1,6 @@
|
|||||||
import webbrowser
|
import webbrowser
|
||||||
import ddg
|
from duckduckgo_search import DDGS
|
||||||
|
|
||||||
def search(query: str) -> None:
|
def search(query):
|
||||||
"""Performs a web search using the default browser.
|
results = DDGS().text("python programming", max_results=10)
|
||||||
|
print(results)
|
||||||
Args:
|
|
||||||
query (str): The search query.
|
|
||||||
"""
|
|
||||||
if not query:
|
|
||||||
raise ValueError("Search query cannot be empty.")
|
|
||||||
|
|
||||||
url = f"https://www.google.com/search?q={query.replace(' ', '+')}"
|
|
||||||
webbrowser.open(url)
|
|
||||||
Reference in New Issue
Block a user