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

Fix lecker.de articles #611

Merged
merged 6 commits into from Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions recipe_scrapers/lecker.py
Expand Up @@ -12,7 +12,16 @@ def author(self):
return self.schema.author()

def title(self):
return self.schema.title()
try:
return self.schema.title()
except TypeError:
return (
self.soup.find(
"header", {"class": "article-header article-header--article"}
)
.find("h1")
.get_text()
)

def category(self):
return self.schema.category()
Expand All @@ -36,7 +45,13 @@ def ingredients(self):
return self.schema.ingredients()

def instructions(self):
return self.schema.instructions()
if self.schema.instructions():
return self.schema.instructions()
else:
divs = self.soup.find_all("div", {"class": "js-quizToggle"})
for d in divs:
if d.find("span", "article__shifted-jump-label"):
return d.get_text()

def ratings(self):
return self.schema.ratings()
Expand Down
Expand Up @@ -276,20 +276,20 @@ jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","setHasJsCookie"
bdu_screen_init();

if (bdu_screen == 'smartphone') {
var iam_data = {
"st":"moblecke",
"cp":"LE_Rezepte_Einzel",
"sv":"mo",
"sc":"yes"
}
var iam_data = {
"st":"moblecke",
"cp":"LE_Rezepte_Einzel",
"sv":"mo",
"sc":"yes"
}
iom.h(iam_data);
} else {
var iam_data = {
"st":"leckerde",
"cp":"LE_Rezepte_Einzel",
"sv":"in",
"sc":"yes"
}
vabene1111 marked this conversation as resolved.
Show resolved Hide resolved
var iam_data = {
"st":"leckerde",
"cp":"LE_Rezepte_Einzel",
"sv":"in",
"sc":"yes"
}
iom.c(iam_data);
}
//--><!]]>
Expand Down
1,878 changes: 1,878 additions & 0 deletions tests/test_data/lecker_2.testhtml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions tests/test_lecker.py → tests/test_lecker_1.py
Expand Up @@ -6,6 +6,10 @@ class TestLeckerScraper(ScraperTest):

scraper_class = Lecker

@property
def test_file_name(self):
return "{}_1".format(self.scraper_class.__name__.lower())

def test_host(self):
self.assertEqual("lecker.de", self.harvester_class.host())

Expand Down
38 changes: 38 additions & 0 deletions tests/test_lecker_2.py
@@ -0,0 +1,38 @@
from recipe_scrapers.lecker import Lecker
from tests import ScraperTest


class TestLeckerScraper(ScraperTest):

scraper_class = Lecker

@property
def test_file_name(self):
return "{}_2".format(self.scraper_class.__name__.lower())

def test_host(self):
self.assertEqual("lecker.de", self.harvester_class.host())

def test_title(self):
self.assertEqual(
"Naan-Brot backen - so geht das Rezept",
self.harvester_class.title(),
)

def test_image(self):
self.assertEqual(
"https://www.lecker.de/assets/field/image/naan-brot-b_0.jpg",
self.harvester_class.image(),
)

def test_ingredients(self):
self.assertEqual(
[],
self.harvester_class.ingredients(),
)

def test_instructions(self):
self.assertIn(
"Als Naan-Brot bezeichnet man dünne Teigfladen aus m",
vabene1111 marked this conversation as resolved.
Show resolved Hide resolved
self.harvester_class.instructions(),
)