deedy5 / duckduckgo_search

Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com search engine. Downloading files and images to a local hard drive.
MIT License
932 stars 117 forks source link

issue with image search #147

Closed keith-nisbet closed 6 months ago

keith-nisbet commented 6 months ago

error returned when trying to run image search

duckduckgo_search.exceptions.DuckDuckGoSearchException: _get_url() https://duckduckgo.com/i.js APIException: _get_url() https://duckduckgo.com/i.js 500 in url

steps to reproduce -

from duckduckgo_search import DDGS with DDGS() as ddgs: keywords = 'butterfly' ddgs_images_gen = ddgs.images( keywords, region="wt-wt", safesearch="off", size=None, color="Monochrome", type_image=None, layout=None, license_image=None, max_results=100, ) for r in ddgs_images_gen: print(r)

results in following error trace -

_Traceback (most recent call last): File "/Users/keithnisbet/Bubblr/ew/ew-nlp/venv/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search.py", line 46, in _get_url if _is_500_in_url(str(resp.url)) or resp.status_code == 403: duckduckgo_search.exceptions.APIException: _get_url() https://duckduckgo.com/i.js 500 in url During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 15, in File "/Users/keithnisbet/Bubblr/ew/ew-nlp/venv/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search.py", line 381, in images license_image = f"license:{license_image}" if license_image else "" File "/Users/keithnisbet/Bubblr/ew/ew-nlp/venv/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search.py", line 57, in _get_url except httpx.HTTPError as ex: duckduckgo_search.exceptions.DuckDuckGoSearchException: _get_url() https://duckduckgo.com/i.js APIException: _geturl() https://duckduckgo.com/i.js 500 in url

Are DDG making changes or are there regular issues like this - I am thinking may have to use a different search engine

deedy5 commented 6 months ago

Thanks for finding the error. Fixed in v3.9.11.

Unfortunately, things change very quickly on the internet. There is no guarantee that what works now will not stop working tomorrow.