From 16d56a6987aa69d5e313c2f1bbe7055d1c34fa1f Mon Sep 17 00:00:00 2001 From: deedy5 <65482418+deedy5@users.noreply.github.com> Date: Fri, 10 Nov 2023 21:31:20 +0000 Subject: [PATCH] V3.9.5 (#132) 1) BUGFIX in images() function: add "Accept" parameter to requests, 2) update requirements to use httpx 0.25.1 version (Add support for Python 3.12). --- duckduckgo_search/duckduckgo_search.py | 2 +- duckduckgo_search/duckduckgo_search_async.py | 2 +- duckduckgo_search/version.py | 2 +- pyproject.toml | 4 ++-- requirements.txt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/duckduckgo_search/duckduckgo_search.py b/duckduckgo_search/duckduckgo_search.py index 00c32796..c973092a 100644 --- a/duckduckgo_search/duckduckgo_search.py +++ b/duckduckgo_search/duckduckgo_search.py @@ -29,6 +29,7 @@ def __init__(self, headers=None, proxies=None, timeout=10) -> None: if headers is None: headers = { "User-Agent": choice(USERAGENTS), + "Accept": "application/json, text/javascript, */*; q=0.01", "Referer": "https://duckduckgo.com/", } self._client = httpx.Client(headers=headers, proxies=proxies, timeout=timeout, http2=True) @@ -361,7 +362,6 @@ def images( payload = { "l": region, "o": "json", - "s": 0, "q": keywords, "vqd": vqd, "f": f"{timelimit},{size},{color},{type_image},{layout},{license_image}", diff --git a/duckduckgo_search/duckduckgo_search_async.py b/duckduckgo_search/duckduckgo_search_async.py index fbd0d5e0..4816c31f 100644 --- a/duckduckgo_search/duckduckgo_search_async.py +++ b/duckduckgo_search/duckduckgo_search_async.py @@ -29,6 +29,7 @@ def __init__(self, headers=None, proxies=None, timeout=10) -> None: if headers is None: headers = { "User-Agent": choice(USERAGENTS), + "Accept": "application/json, text/javascript, */*; q=0.01", "Referer": "https://duckduckgo.com/", } self._client = httpx.AsyncClient(headers=headers, proxies=proxies, timeout=timeout, http2=True) @@ -363,7 +364,6 @@ async def images( payload = { "l": region, "o": "json", - "s": 0, "q": keywords, "vqd": vqd, "f": f"{timelimit},{size},{color},{type_image},{layout},{license_image}", diff --git a/duckduckgo_search/version.py b/duckduckgo_search/version.py index cab24240..6ea38dc2 100755 --- a/duckduckgo_search/version.py +++ b/duckduckgo_search/version.py @@ -1 +1 @@ -__version__ = "3.9.4" +__version__ = "3.9.5" diff --git a/pyproject.toml b/pyproject.toml index b895543a..0f11e9b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ "aiofiles>=23.2.1", "click>=8.1.7", "lxml>=4.9.3", - "httpx[http2,socks,brotli]>=0.25.0", + "httpx[http2,socks,brotli]>=0.25.1", ] dynamic = ["version"] @@ -45,7 +45,7 @@ ddgs = "duckduckgo_search.cli:cli" version = {attr = "duckduckgo_search.version.__version__"} [project.optional-dependencies] -dev = [ +dev = [ "black>=23.9.1", "isort>=5.12.0", "ruff>=0.0.291", diff --git a/requirements.txt b/requirements.txt index d265fe96..23613ed6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ aiofiles>=23.2.1 click>=8.1.7 lxml>=4.9.3 -httpx[http2,socks,brotli]>=0.25.0 +httpx[http2,socks,brotli]>=0.25.1