Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example stopped working #15

Open
tillea opened this issue Feb 8, 2024 · 2 comments
Open

Example stopped working #15

tillea opened this issue Feb 8, 2024 · 2 comments

Comments

@tillea
Copy link

tillea commented Feb 8, 2024

Hi,
if I try to run your simple example from README.md I get:

from duckpy import Client
client = Client()
results = client.search("Python Wikipedia")
print(results)
[]

This has led to a bug for the Debian packaged duckpy. The problem exists for Python3.11 and Python3.12.
Kind regards, Andreas.

@alissonlauffer
Copy link
Member

Hello, and thanks for reaching out. An empty results list usually means that DuckDuckGo has blocked your IP. I have just tried here with my home IP, and it worked fine:

>>> from duckpy import Client
>>> client = Client()
>>> results = client.search("Python Wikipedia")
>>> print(results[0])
{'title': 'Python (programming language) - Wikipedia', 'description': 'Python is a high-level, general-purpose programming language.Its design philosophy emphasizes code readability with the use of significant indentation.. Python is dynamically typed and garbage-collected.It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming.It is often described as a "batteries included" language ...', 'url': 'https://en.wikipedia.org/wiki/Python_(programming_language)'}

Either way, an error should be raised if your IP is blocked, rather than just blindly returning an empty list (which is also the behaviour for not found queries). This project was made in a very rudimentary way, so there's a lot of room for improvements.

@tillea
Copy link
Author

tillea commented Feb 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants