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

Absorb base repo #1

Merged
merged 4 commits into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions recipe_scrapers/_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ def __init__(self, url, exception_handling=True, meta_http_equiv=False, test=Fal
def url(self):
return self.url

def host(self):
""" get the host of the url, so we can use the correct scraper """
@classmethod
def host(cls):
""" get the hostdef of the url, so we can use the correct scraper """
raise NotImplementedError("This should be implemented.")

@Decorators.normalize_string_output
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/_schemaorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def image(self):
return image[0].get('url')
return image[0]

if self.host not in image:
if 'http://' not in image and 'https://' not in image:
# some sites give image path relative to the domain
# in cases like this handle image url with class methods or og link
return ''
Expand Down
33 changes: 19 additions & 14 deletions recipe_scrapers/acouplecooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

class ACoupleCooks(AbstractScraper):
@classmethod
def host(self):
def host(cls):
return 'acouplecooks.com'

def title(self):
return self.soup.find(
'h2',
{'class': 'tasty-recipes-title'}
'h2',
{'class': 'tasty-recipes-title'}
).get_text()

def total_time(self):
return get_minutes(self.soup.find(
'span',
Expand All @@ -24,16 +24,21 @@ def yields(self):
'span',
{'class': 'tasty-recipes-yield'}).span
)

def ingredients(self):
return [normalize_string(child.text) for child in self.soup.find(
'div',
{'class':'tasty-recipes-ingredients'}).ul.children]

return [
normalize_string(child.text)
for child in self.soup.find(
'div',
{'class': 'tasty-recipes-ingredients'}
).ul.children
]

def instructions(self):
return "\n".join([instruction.text for instruction in self.soup.find(
'div',
{'class':'tasty-recipes-instructions'}).ol.children
return "\n".join([
instruction.text for instruction in
self.soup.find(
'div',
{'class': 'tasty-recipes-instructions'}
).ol.children
])


23 changes: 22 additions & 1 deletion recipe_scrapers/allrecipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,26 @@
class AllRecipes(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'allrecipes.com'

def title(self):
return self.schema.title()

def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()

def image(self):
return self.schema.image()

def ingredients(self):
return self.schema.ingredients()

def instructions(self):
return self.schema.instructions()

def ratings(self):
return self.schema.ratings()
20 changes: 19 additions & 1 deletion recipe_scrapers/archanaskitchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,23 @@
class ArchanasKitchen(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'archanaskitchen.com'

def title(self):
return self.schema.title()

def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()

def ingredients(self):
return self.schema.ingredients()

def instructions(self):
return self.schema.instructions()

def ratings(self):
return self.schema.ratings()
2 changes: 1 addition & 1 deletion recipe_scrapers/bbcgoodfood.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class BBCGoodFood(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'bbcgoodfood.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/bettycrocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class BettyCrocker(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'bettycrocker.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/bonappetit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class BonAppetit(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'bonappetit.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/budgetbytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class BudgetBytes(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'budgetbytes.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/closetcooking.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class ClosetCooking(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'closetcooking.com'

def title(self):
Expand Down
4 changes: 2 additions & 2 deletions recipe_scrapers/cookieandkate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class CookieAndKate(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'cookieandkate.com'

def title(self):
Expand Down Expand Up @@ -56,4 +56,4 @@ def ratings(self):
"span",
{"class": "average"}
).get_text()), 2
)
)
23 changes: 22 additions & 1 deletion recipe_scrapers/cookpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,26 @@
class CookPad(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'cookpad.com'

def title(self):
return self.schema.title()

def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()

def image(self):
return self.schema.image()

def ingredients(self):
return self.schema.ingredients()

def instructions(self):
return self.schema.instructions()

def ratings(self):
return self.schema.ratings()
2 changes: 1 addition & 1 deletion recipe_scrapers/cookstr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Cookstr(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'cookstr.com'

def title(self):
Expand Down
8 changes: 4 additions & 4 deletions recipe_scrapers/copykat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class CopyKat(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'copykat.com'

def title(self):
Expand All @@ -30,7 +30,7 @@ def total_time(self):
{'class': 'wprm-recipe-details wprm-recipe-details-minutes wprm-recipe-total_time wprm-recipe-total_time-minutes'}
).get_text()
if tt1:
tt3 = (int(tt1)*60) + int(tt2)
tt3 = (int(tt1) * 60) + int(tt2)
tt2 = get_minutes(tt3)
if tt3 and (tt2 == 0):
total_time = tt3
Expand Down Expand Up @@ -70,7 +70,7 @@ def ingredients(self):
'class': "wprm-recipe-group-name wprm-recipe-ingredient-group-name wprm-block-text-bold"}).text
except Exception:
header = None
if header != None:
if header is not None:
ingGroup.append(header)
ingredparts = ig.findAll('li')
for i in ingredparts:
Expand All @@ -91,7 +91,7 @@ def instructions(self):
{'class': 'wprm-recipe-group-name wprm-recipe-instruction-group-name wprm-block-text-bold'}).text
except Exception:
header = None
if header != None:
if header is not None:
data.append(header)
ins = instruct.findAll(
'div', {'class': 'wprm-recipe-instruction-text'})
Expand Down
4 changes: 2 additions & 2 deletions recipe_scrapers/countryliving.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class CountryLiving(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'countryliving.com'

def title(self):
Expand Down Expand Up @@ -48,4 +48,4 @@ def instructions(self):
return '\n'.join([
normalize_string(instruction.get_text())
for instruction in instructions
])
])
23 changes: 22 additions & 1 deletion recipe_scrapers/cybercook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,26 @@
class Cybercook(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'cybercook.com.br'

def title(self):
return self.schema.title()

def total_time(self):
return self.schema.total_time()

def yields(self):
return self.schema.yields()

def image(self):
return self.schema.image()

def ingredients(self):
return self.schema.ingredients()

def instructions(self):
return self.schema.instructions()

def ratings(self):
return self.schema.ratings()
3 changes: 2 additions & 1 deletion recipe_scrapers/delish.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from ._abstract import AbstractScraper
from ._utils import get_minutes, normalize_string, get_yields


class Delish(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'delish.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/epicurious.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Epicurious(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'epicurious.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/finedininglovers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class FineDiningLovers(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'finedininglovers.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/fitmencook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class FitMenCook(AbstractScraper):
@classmethod
def host(self):
def host(cls):
return "fitmencook.com"

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/food.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Food(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'food.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/foodnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class FoodNetwork(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'foodnetwork.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/foodrepublic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class FoodRepublic(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'foodrepublic.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/geniuskitchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class GeniusKitchen(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'geniuskitchen.com'

def title(self):
Expand Down
2 changes: 1 addition & 1 deletion recipe_scrapers/giallozafferano.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class GialloZafferano(AbstractScraper):

@classmethod
def host(self):
def host(cls):
return 'ricette.giallozafferano.it'

def title(self):
Expand Down
Loading