Skip to content

Commit

Permalink
html update (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
jknndy authored Feb 2, 2025
1 parent 00a6c82 commit 9f9c61c
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 174 deletions.
39 changes: 1 addition & 38 deletions recipe_scrapers/panelinha.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,14 @@
import re

from ._abstract import AbstractScraper
from ._utils import get_minutes, get_yields, normalize_string

INSTRUCTIONS_NUMBERING_REGEX = re.compile(r"^\d{1,2}\.\s*") # noqa
from ._utils import get_minutes, get_yields


class Panelinha(AbstractScraper):
@classmethod
def host(cls):
return "panelinha.com.br"

def ingredients(self):
ingredients = self.soup.find("h5", string="Ingredientes").nextSibling.findAll(
"li"
)

return [
normalize_string(ingredient.get_text().replace("\u00C2", ""))
for ingredient in ingredients
]

def instructions(self):
instructions = self.soup.find(
"h5", string="Modo de preparo"
).nextSibling.findAll("li")

instructions = [
normalize_string(instruction.get_text()) for instruction in instructions
]

# Some recipes pages have a different html structure.
if not instructions:
instructions = self.soup.find(
"h4", string="Modo de preparo"
).nextSibling.p.strings

instructions = (
normalize_string(instruction) for instruction in instructions
)

instructions = map(
lambda step: INSTRUCTIONS_NUMBERING_REGEX.sub("", step), instructions
)

return "\n".join(instructions)

def yields(self):
main_element = self.soup.find("main")
yield_text = main_element.get("data-item-p-yield")
Expand Down
14 changes: 7 additions & 7 deletions tests/test_data/panelinha.com.br/panelinha_1.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"author": "Panelinha",
"canonical_url": "panelinha.com.br",
"canonical_url": "https://panelinha.com.br/receita/rosbife",
"site_name": "Panelinha - Receitas que funcionam",
"host": "panelinha.com.br",
"language": "pt-br",
"title": "Rosbife",
"ingredients": [
"750 g de filé mignon em peça para rosbife",
"1 colher (chá) de mostarda amarela em pó",
"1 colher (chá) de páprica defumada",
"750 g de filé mignon em peça para rosbife",
"1 colher (chá) de mostarda amarela em ",
"1 colher (chá) de páprica defumada",
"azeite a gosto",
"sal e pimenta-do-reino moída na hora a gosto"
"sal e pimenta-do-reino moída na hora a gosto"
],
"instructions_list": [
"Preaqueça o forno a 220 ºC (temperatura alta). Retire a peça de filé mignon da geladeira e deixe em temperatura ambiente por 15 minutos, enquanto o forno aquece.",
Expand All @@ -20,8 +20,8 @@
],
"category": "Carnes,Pratos principais",
"yields": "4 servings",
"description": "Clássico é clássico! Com a técnica certa, o rosbife fica perfeito. Atente para os tempos e as temperaturas. Ele não pode estar gelado e precisa mesmo do descanso depois de assado.",
"description": "Clássico é clássico! Com a técnica certa, o rosbife fica perfeito. Atente para os tempos e as temperaturas. Ele não pode estar gelado e precisa mesmo do descanso depois de assado.",
"total_time": 60,
"cuisine": "Inglesa,Prática,Clássica,Argentina,Sem Glúten",
"cuisine": "Inglesa,Prática,Clássica,Argentina,Sem Glúten",
"image": "https://i.panelinha.com.br/i1/228-q-9959-rosbife.webp"
}
Loading

0 comments on commit 9f9c61c

Please sign in to comment.