From c99c44616c4bf432c2eb5426a266224447f4e5f0 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 2 Apr 2014 20:08:56 +1300 Subject: [PATCH] Adapted code to get multiple results! --- plugins/recipe.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/recipe.py b/plugins/recipe.py index 8b4438c..c9c1c90 100644 --- a/plugins/recipe.py +++ b/plugins/recipe.py @@ -52,13 +52,16 @@ def recipe(inp): return "Could not get recipe: {}".format(e) # find the list of results - results = search.find('div', {'class': 'found_results'}) + result_list = search.find('div', {'class': 'found_results'}) - if results: - result = results.find('div', {'class': 'recipe_result'}) + if result_list: + results = result_list.find_all('div', {'class': 'recipe_result'}) else: return "No results" + # pick a random front page result + result = random.choice(results) + # extract the URL from the result url = BASE_URL + result.find('div', {'class': 'image-wrapper'}).find('a')['href']