Skip to content

BingImages backend ignores safesearch for image search #468

Description

@GreenRays

Before you open an issue:

  • [x ] I have the latest version
  • I tried reinstalling the library. (pip install -I ddgs)
  • I tried using a proxy

Describe the bug

The BingImages backend accepts the shared safesearch argument from DDGS.images(...), but does not apply it to the Bing image request payload.

When calling DDGS.images(..., safesearch="on", backend="bing") or backend="auto" when it falls back to Bing, I would expect Bing image search to receive an equivalent strict SafeSearch parameter. Instead, the Bing payload appears to omit SafeSearch entirely.

In ddgs/engines/bing_images.py, build_payload() currently receives safesearch but marks it unused:

Steps to reproduce the problem:
from ddgs import DDGS

with DDGS() as ddgs:
results = ddgs.images(
"deep sea fish",
safesearch="on",
backend="bing",
max_results=10,
)

Observe the Bing request URL/logs. It calls:

https://www.bing.com/images/async?q=deep+sea+fish&async=1&first=1&count=...
Expected:

https://www.bing.com/images/async?q=deep+sea+fish&async=1&first=1&count=...&safeSearch=Strict

Specify this information

  • OS: macOS
  • environment: Python 3.12
  • ddgs version: 9.14.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions