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

Error on line 89 #3

Closed DNA2RNA closed 2 years ago

DNA2RNA commented 2 years ago

The following search strings failed:

And other similar search strings. Other string worked. There seems to be some sort of inconsistency. Not sure why. Maybe something to do with the cache?

Traceback (most recent call last):
  File "/home/DNA/anaconda3/lib/python3.8/site-packages/duckduckgo_search.py", line 89, in ddg
    s = r["n"].split("s=")[1].split('&')[0]
KeyError: 'n'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ducksearch.py", line 20, in <module>
    results = ddg(search_str, region='wt-wt', safesearch='Moderate', time=None, max_results=25)
  File "/home/DNA/anaconda3/lib/python3.8/site-packages/duckduckgo_search.py", line 98, in ddg
    'body': _normalize(r['a']),
  File "/home/DNA/anaconda3/lib/python3.8/site-packages/duckduckgo_search.py", line 39, in _normalize
    body = html.fromstring(text)
  File "/home/DNA/anaconda3/lib/python3.8/site-packages/lxml/html/__init__.py", line 875, in fromstring
    doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
  File "/home/DNA/anaconda3/lib/python3.8/site-packages/lxml/html/__init__.py", line 763, in document_fromstring
    raise etree.ParserError(
lxml.etree.ParserError: Document is empty