gleitz / howdoi

instant coding answers via the command line
http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line
MIT License
10.62k stars 869 forks source link

Duckduckgo issue #404

Open gleitz opened 3 years ago

gleitz commented 3 years ago

What happened:

Duckduckgo seems to be blocking requests

What you expected to happen:

Request should succeed

Output with --explain

» python -m howdoi make a pizza --engine duckduckgo --explain
INFO: Version: 2.0.16
INFO: Fetching answers for query: make a pizza
INFO: Searching duckduckgo with URL: https://duckduckgo.com/html?q=site:stackoverflow.com%20make%20a%20pizza&t=hj&ia=web
INFO: Received HTTPError
ERROR: Unable to find an answer because the search engine temporarily blocked the request. Please wait a few minutes or select a different search engine.
Traceback (most recent call last):
  File "/Users/gleitz/.homebrew/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/gleitz/.homebrew/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/gleitz/projects/howdoi/howdoi/__main__.py", line 3, in <module>
    command_line_runner()
  File "/Users/gleitz/projects/howdoi/howdoi/howdoi.py", line 788, in command_line_runner
    utf8_result = howdoi(args).encode('utf-8', 'ignore')
  File "/Users/gleitz/projects/howdoi/howdoi/howdoi.py", line 615, in howdoi
    res = _get_answers(args)
  File "/Users/gleitz/projects/howdoi/howdoi/howdoi.py", line 418, in _get_answers
    question_links = _get_links_with_cache(args['query'])
  File "/Users/gleitz/projects/howdoi/howdoi/howdoi.py", line 397, in _get_links_with_cache
    links = _get_links(query)
  File "/Users/gleitz/projects/howdoi/howdoi/howdoi.py", line 282, in _get_links
    raise BlockError('Temporary block by search engine')
howdoi.howdoi.BlockError: Temporary block by search engine

When I open the page referenced, I occasionally get the error

If this error persists, please let us know: error-lite@duckduckgo.com
ShezaMunir commented 3 years ago

Reminder: once this issue is resolved, enable DDG test case in test_howdoi.py

SaurusXI commented 3 years ago

@gleitz perhaps using a headless browser like puppeteer or selenium might fix this problem? Not sure how it would affect performance, but might be worth looking into.

alirazacodes commented 3 years ago

Hi @gleitz, I would like to contribute to resolving this issue;

Please do assign me this issue, I have already started working on it, having some issues while running howdoi in my local machine due to some python packages being broken while installation which will be resolved by today.