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
1.13k stars 131 forks source link

While searching for words, he stays in bug and enters an endless wait #8

Closed kerafb closed 2 years ago

kerafb commented 2 years ago

I am using this code. I am searching by scraping words from a txt file. Sometimes, as a result of the word search, it enters the bug and waits for hours. It goes into an endless sleep cycle. And goes to sleep for hours without finding any results

from duckduckgo_search import ddg

keywords = 'Bella Ciao'
results = ddg(keywords, region='wt-wt', safesearch='Moderate', time='y', max_results=28)
print(results)
deedy5 commented 2 years ago

Hi. 1) Update the package.

python3 -m pip install -U duckduckgo_search

2) Are you taking this into account?

WARNING!: set a delay of at least 0.75 seconds between function calls.

3) Show me your code.

kerafb commented 2 years ago

I'm searching for this word. Not responding Clean eating lunches

I am using this code

from duckduckgo_search import ddg

keywords = 'Clean eating lunches'
results = ddg(keywords, region='wt-wt', safesearch='Moderate', time='y', max_results=100)
print(results)
deedy5 commented 2 years ago

Your code works

from duckduckgo_search import ddg

keywords = 'Clean eating lunches'
results = ddg(keywords, region='wt-wt', safesearch='Moderate', time='y', max_results=100)
print(results)

Output:

[
  {
    "title": "Gluten-Free Lunch Recipes - Clean Eating Kitchen",
    "href": "https://www.cleaneatingkitchen.com/category/lunch-recipes/",
    "body": "Healthy Tuna Pasta Salad Instant Pot Red Lentil Dal Vitamix Tomato Soup (Vegan) Erewhon Kale Salad (Copycat) Lentil Turkey Soup Cranberry Walnut Chicken Salad Panera Chicken Noodle Soup (Copycat) Air Fryer Corn Dogs Vegan Potato Leek Soup (Instant Pot or Stovetop) 5-Ingredient Healthy Chicken Salad Buckwheat Bread"
  },
...
]
kerafb commented 2 years ago

Found the solution to the problem. I set 100 results for each word. For some words, for example, when it finds 50 or 60 results, it queries again and again forever and continues in this way because it cannot produce 100 results. I solved the problem by editing the library with a programmer. Thank you

deedy5 commented 2 years ago

Great. But with the keywords you pointed out, I could not reproduce your problem. I don't mind if your programmer makes a pull request to fix the bug, if it exists.

kerafb commented 2 years ago

Thanks.