-
Notifications
You must be signed in to change notification settings - Fork 531
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
Added scraper for Drinkoteket.se #1043
Open
Pebkac03
wants to merge
4
commits into
hhursev:main
Choose a base branch
from
Pebkac03:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,53 @@ | ||||||
# mypy: allow-untyped-defs | ||||||
|
||||||
from ._abstract import AbstractScraper | ||||||
|
||||||
|
||||||
class Drinkoteket(AbstractScraper): | ||||||
@classmethod | ||||||
def host(cls): | ||||||
return "drinkoteket.se" | ||||||
|
||||||
def author(self): | ||||||
return self.schema.author() | ||||||
|
||||||
def title(self): | ||||||
return self.schema.title() | ||||||
|
||||||
def category(self): | ||||||
return self.schema.category() | ||||||
|
||||||
def total_time(self): | ||||||
return self.schema.total_time() | ||||||
|
||||||
def yields(self): | ||||||
return 1 | ||||||
|
||||||
def image(self): | ||||||
return self.schema.image() | ||||||
|
||||||
def ingredients(self): | ||||||
ingredients_element = self.soup.find("ul", {"class": "ingredients"}) | ||||||
|
||||||
ingredients_separator = ingredients_element.find("li", {"class": "separator"}) | ||||||
|
||||||
if ingredients_separator is not None: | ||||||
separator_index = ingredients_element.index(ingredients_separator) | ||||||
raw_list = ingredients_element.findAll("span")[0::2][:separator_index] | ||||||
else: | ||||||
raw_list = ingredients_element.findAll("span")[0::2] | ||||||
|
||||||
ingredients = [i.getText().strip() for i in raw_list] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A small cleanup suggestion:
Suggested change
|
||||||
return ingredients | ||||||
|
||||||
def instructions(self): | ||||||
return self.schema.instructions() | ||||||
|
||||||
def ratings(self): | ||||||
return self.schema.ratings() | ||||||
|
||||||
def cuisine(self): | ||||||
return self.schema.cuisine() | ||||||
|
||||||
def description(self): | ||||||
return self.schema.description() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"author": "Drinkoteket", | ||
"canonical_url": "https://drinkoteket.se/recept/margarita/", | ||
"host": "drinkoteket.se", | ||
"description": "Margarita är en klassisk drink och finns i en uppsjö av varianter. Det här är originalet. Ett vanligt misstag är att man väljer en tequila som man inte tycker om. Eftersom tequilan utgör 50% av drinken innebär det ofta att man inte heller gillar Margaritan man just har blandat. Prova dig därför fram för att hitta en tequila som du gillar.", | ||
"image": "https://drinkoteket.se/wp-content/uploads/margarita-1-860x860.jpg", | ||
"ingredients": [ | ||
"4 cl Tequila", | ||
"2 cl Apelsinlikör (Triple sec)", | ||
"2 cl Limejuice" | ||
], | ||
"ingredient_groups": [ | ||
{ | ||
"ingredients": [ | ||
"4 cl Tequila", | ||
"2 cl Apelsinlikör (Triple sec)", | ||
"2 cl Limejuice" | ||
], | ||
"purpose": null | ||
} | ||
], | ||
"instructions": "Förbered margarita-glaset genom att först sprida ut ett lager salt på ett fat.\nFukta glasets kanter med en limeklyfta.\nDoppa glaset i saltet så att det fastnar. Ett tips om du serverar drinken till någon annan än dig själv är att endast salta halva glaset så kan den som dricker Margaritan själv välja att dricka med eller utan salt.\nBlanda alla ingredienser i en shaker.\nFyll shakern med is och skaka.\nSila upp drinken i glaset.\nGarnera med en limeklyfta.\n\nOm man tycker att drinken blir för \"spetsig\" i sin smak, kan man tillsätta ca 0,5-1 cl sockerlag för att runda av och balansera smakerna. Som med alla drinkar handlar det i grund och botten om vad man själv gillar, så testa dig fram för att optimera receptet utifrån dina preferenser.\n\nHur gör du din Margarita?", | ||
"instructions_list": [ | ||
"Förbered margarita-glaset genom att först sprida ut ett lager salt på ett fat.", | ||
"Fukta glasets kanter med en limeklyfta.", | ||
"Doppa glaset i saltet så att det fastnar. Ett tips om du serverar drinken till någon annan än dig själv är att endast salta halva glaset så kan den som dricker Margaritan själv välja att dricka med eller utan salt.", | ||
"Blanda alla ingredienser i en shaker.", | ||
"Fyll shakern med is och skaka.", | ||
"Sila upp drinken i glaset.", | ||
"Garnera med en limeklyfta.", | ||
"Om man tycker att drinken blir för \"spetsig\" i sin smak, kan man tillsätta ca 0,5-1 cl sockerlag för att runda av och balansera smakerna. Som med alla drinkar handlar det i grund och botten om vad man själv gillar, så testa dig fram för att optimera receptet utifrån dina preferenser.", | ||
"Hur gör du din Margarita?" | ||
], | ||
"language": "sv-SE", | ||
"site_name": "Drinkoteket", | ||
"title": "Margarita", | ||
"total_time": 8, | ||
"yields": 1 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @Pebkac03!
The only quibble I have is this
return 1
. I guess it makes sense that most/all of the recipes will be for a single instance of whatever cocktail is being prepared. Could you check for counter-examples even so?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you're right. Found that some recipes where for two servings. Will probably work on it tomorrow.