Airsc miễn phí cho tất cả. Nếu nó giúp bạn, hãy ủng hộ $2–$20.

Ủng hộ
MCP serverAn toànTự động trình duyệt & dữ liệu webCần cài đặt chút

ddgs

deedy5 · deedy5/ddgs

Tích hợp thư viện tìm kiếm tổng hợp vào một AI agent, cho phép nó tổng hợp kết quả tìm kiếm từ nhiều dịch vụ web khác nhau.

Một thư viện metasearch tổng hợp kết quả từ các dịch vụ tìm kiếm web đa dạng

3k sao286Giấy phép: MITCập nhật 2 tháng trước0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Nghiên cứu một chủ đề bằng cách tổng hợp kết quả từ nhiều công cụ tìm kiếm.
  • Tìm kiếm hình ảnh hoặc video cụ thể bằng cách truy vấn các nguồn web đa dạng.
  • Trích xuất các bài báo hoặc nội dung từ URL để tóm tắt.

Kiểm tra an toàn

An toàn

Không thấy dấu hiệu rủi ro trong các file đã quét.

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ README

DDGS | Dux Distributed Global Search

A metasearch library that aggregates results from diverse web search services.

Table of Contents


Install

pip install -U ddgs       # Base install
pip install -U ddgs[api]  # API server (FastAPI)
pip install -U ddgs[mcp]  # MCP server (stdio)

CLI version

ddgs - -help

Go To TOP


API Server

-- Install

pip install -U ddgs[api]

-- CLI

ddgs api              # Start server in foreground
ddgs api -d           # Start in detached mode (background)
ddgs api -s           # Stop detached server
ddgs api --host 127.0.0.1 --port 4479  # Default port 4479
ddgs api -pr socks5h://127.0.0.1:9150  # With proxy

-- Docker compose

git clone https://github.com/deedy5/ddgs && cd ddgs
docker-compose up --build

-- Bash script

git clone https://github.com/deedy5/ddgs && cd ddgs
chmod +x start_api.sh
./start_api.sh

Endpoints

EndpointMethodDescription
/search/textGET, POSTText search
/search/imagesGET, POSTImage search
/search/newsGET, POSTNews search
/search/videosGET, POSTVideo search
/search/booksGET, POSTBook search
/extractGET, POSTExtract content from URL
/healthGETHealth check
/docsGETSwagger UI
/redocGETReDoc documentation

Go To TOP


MCP Server

  • Install
pip install -U ddgs[mcp]
  • CLI
ddgs mcp    # Start MCP server (stdio transport)
ddgs mcp -pr socks5h://127.0.0.1:9150  # With proxy

Available Tools

ToolDescription
search_textWeb text search
search_imagesImage search
search_newsNews search
search_videosVideo search
search_booksBook search
extract_contentExtract content from a URL

Client Configuration

For MCP clients like Cursor or Claude Desktop:

{
  "mcpServers": {
    "ddgs": {
      "command": "ddgs",
      "args": ["mcp"]
    }
  }
}

Go To TOP


Engines

DDGS functionAvailable backends
text()bing, brave, duckduckgo, google, grokipedia, mojeek, startpage, yandex, yahoo, wikipedia
images()bing, duckduckgo
videos()duckduckgo
news()bing, duckduckgo, yahoo
books()annasarchive

Go To TOP

DDGS class

DDGS class is lazy-loaded.

class DDGS:
    """Dux Distributed Global Search. A metasearch library that aggregates results from diverse web search services.

    Args:
        proxy (str, optional): proxy for the HTTP client, supports http/https/socks5 protocols.
            example: "http://user:pass@example.com:3128". Defaults to None.
        timeout (int, optional): Timeout value for the HTTP client. Defaults to 5.
        verify: (bool | str):  True to verify, False to skip, or a str path to a PEM file. Defaults to True.
    """

Here is an example of initializing the DDGS class.

from ddgs import DDGS

results = DDGS().text("python programming", max_results=5)
print(results)

Go To TOP

1. text()

def text(
    query: str,
    region: str = "us-en",
    safesearch: str = "moderate",
    timelimit: str | None = None,
    max_results: int | None = 10,
    page: int = 1,
    backend: str = "auto",
) -> list[dict[str, str]]:
    """DDGS text metasearch.

    Args:
        query: text search query.
        region: us-en, uk-en, ru-ru, etc. Defaults to us-en.
        safesearch: on, moderate, off. Defaults to "moderate".
        timelimit: d, w, m, y. Defaults to None.
        max_results: maximum number of results. Defaults to 10.
        page: page of results. Defaults to 1.
        backend: A single or comma-delimited backends. Defaults to "auto".

    Returns:
        List of dictionaries with search results.
    """

Example

results = DDGS().text("live free or die", region="us-en", safesearch="off", timelimit="y", page=1, backend="auto")
# Searching for pdf files
results = DDGS().text("russia filetype:pdf", region="us-en", safesearch="off", timelimit="y", page=1, backend="auto")
print(results)
[
    {
        "title": "News, sport, celebrities and gossip | The Sun",
        "href": "https://www.thesun.co.uk/",
        "body": "Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The Sun",
    },
    ...,
]

Go To TOP

2. images()

def images(
    query: str,
    region: str = "us-en",
    safesearch: str = "moderate",
    timelimit: str | None = None,
    max_results: int | None = 10,
    page: int = 1,
    backend: str = "auto",
    size: str | None = None,
    color: str | None = None,
    type_image: str | None = None,
    layout: str | None = None,
    license_image: str | None = None,
) -> list[dict[str, str]]:
    """DDGS images metasearch.

    Args:
        query: images search query.
        region: us-en, uk-en, ru-ru, etc. Defaults to us-en.
        safesearch: on, moderate, off. Defaults to "moderate".
        timelimit: d, w, m, y. Defaults to None.
        max_results: maximum number of results. Defaults to 10.
        page: page of results. Defaults to 1.
        backend: A single or comma-delimited backends. Defaults to "auto".
        size: Small, Medium, Large, Wallpaper. Defaults to None.
        color: color, Monochrome, Red, Orange, Yellow, Green, Blue,
            Pur
Xem mã nguồn trên GitHub