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
927 stars 117 forks source link

duckduckgo_search.exceptions.DuckDuckGoSearchException #164

Closed h9052300 closed 5 months ago

h9052300 commented 6 months ago
from duckduckgo_search import DDGS

with DDGS() as ddgs:
    keywords = '蔡英文'
    ddgs_news_gen = ddgs.news(
        keywords,
        region="zh-TW",
        safesearch="Off",
        timelimit="m",
    )
    for r in ddgs_news_gen:
        print(r)
Traceback (most recent call last):
  File "C:\Users\user\Desktop\Python Project\flask_view\venv\lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 46, in _get_url
    raise DuckDuckGoSearchException("Ratelimit")
duckduckgo_search.exceptions.DuckDuckGoSearchException: Ratelimit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\Desktop\Python Project\flask_view\yikogd\ddgoSearch.py", line 129, in <module>
    for r in ddgs_news_gen:
  File "C:\Users\user\Desktop\Python Project\flask_view\venv\lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 508, in news
    vqd = self._get_vqd(keywords)
  File "C:\Users\user\Desktop\Python Project\flask_view\venv\lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 54, in _get_vqd
    resp = self._get_url("POST", "https://duckduckgo.com", data={"q": keywords})
  File "C:\Users\user\Desktop\Python Project\flask_view\venv\lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 50, in _get_url
    raise DuckDuckGoSearchException(f"_get_url() {url} {type(ex).__name__}: {ex}")
duckduckgo_search.exceptions.DuckDuckGoSearchException: _get_url() https://duckduckgo.com DuckDuckGoSearchException: Ratelimit

But when searching with English keywords, everything works fine.

worm128 commented 6 months ago

好像搜索中文都是有这个故障,包括:图片、视频 等接口,只有文本没报错

deedy5 commented 6 months ago

1) region=tw-tzh for Taiwan https://github.com/deedy5/duckduckgo_search#regions, 2) apparently there were some problems on the site, because the code did cause an error, but then it worked properly.

mc-marcocheng commented 5 months ago

@deedy5 I am encountering the same error for chinese text, including ddgs.text.