Skip to content

Commit

Permalink
Fixup: remove overwrite of schema.org data with 'mainEntity' contents…
Browse files Browse the repository at this point in the history
… during schema.org processing (#666)
  • Loading branch information
jayaddison committed Oct 21, 2022
1 parent d839b76 commit 557cfd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 1 addition & 7 deletions recipe_scrapers/_schemaorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,15 @@ def __init__(self, page_data, raw=False):
if in_context and item_type.lower() in low_schema:
self.format = syntax
self.data = item
if item_type.lower() == "webpage":
self.data = self.data.get("mainEntity")
return
elif in_context and "@graph" in item:
for graph_item in item.get("@graph", ""):
graph_item_type = graph_item.get("@type", "")
if not isinstance(graph_item_type, str):
continue
if graph_item_type.lower() in low_schema:
in_graph = SCHEMA_ORG_HOST in graph_item.get("@context", "")
self.format = syntax
if graph_item_type.lower() == "webpage" and in_graph:
self.data = self.data.get("mainEntity")
return
elif graph_item_type.lower() == "recipe":
if graph_item_type.lower() == "recipe":
self.data = graph_item
return

Expand Down
4 changes: 4 additions & 0 deletions recipe_scrapers/sallysblog.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ def instructions(self):
for instruction in instructions
]
)

def image(self):
image = self.soup.find("meta", {"property", "og:image"})
return image["content"] if image else None

0 comments on commit 557cfd9

Please sign in to comment.