cookboob backends : handle bad id

This commit is contained in:
Julien Veyssier 2013-03-17 16:00:51 +01:00
commit 95953d3217
3 changed files with 20 additions and 10 deletions

View file

@ -43,5 +43,5 @@ class SevenFiftyGramsBrowser(BaseBrowser):
def get_recipe(self, id):
self.location('http://www.750g.com/fiche_de_cuisine_complete.htm?recettes_id=%s' % id)
assert self.is_on_page(RecipePage)
return self.page.get_recipe(id)
if self.is_on_page(RecipePage):
return self.page.get_recipe(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import RecipePage, ResultsPage
@ -43,6 +43,11 @@ class CuisineazBrowser(BaseBrowser):
return self.page.iter_recipes()
def get_recipe(self, id):
self.location('http://www.cuisineaz.com/recettes/%s.aspx' % id)
assert self.is_on_page(RecipePage)
return self.page.get_recipe(id)
try:
self.location('http://www.cuisineaz.com/recettes/%s.aspx' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(RecipePage):
return self.page.get_recipe(id)
else:
return

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import RecipePage, ResultsPage
@ -42,6 +42,11 @@ class MarmitonBrowser(BaseBrowser):
return self.page.iter_recipes()
def get_recipe(self, id):
self.location('http://www.marmiton.org/recettes/recette_%s.aspx' % id)
assert self.is_on_page(RecipePage)
return self.page.get_recipe(id)
try:
self.location('http://www.marmiton.org/recettes/recette_%s.aspx' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(RecipePage):
return self.page.get_recipe(id)
else:
return