fix bookmarklet

This commit is contained in:
smilerz
2022-07-06 16:16:53 -05:00
parent 946de2e7e3
commit e23d514d89
4 changed files with 65 additions and 55 deletions

View File

@@ -6,7 +6,7 @@ from urllib.parse import unquote
from bs4 import BeautifulSoup
from bs4.element import Tag
from recipe_scrapers import scrape_html, scrape_me
from recipe_scrapers._exceptions import NoSchemaFoundInWildMode
from recipe_scrapers._exceptions import NoSchemaFoundInWildMode, WebsiteNotImplementedError
from recipe_scrapers._utils import get_host_name, normalize_string
from cookbook.helper import recipe_url_import as helper
@@ -68,11 +68,14 @@ def get_recipe_from_source(text, url, request):
text = unquote(text)
scrape = None
if url:
if url and not text:
try:
scrape = scrape_me(url_path=url, wild_mode=True)
except(NoSchemaFoundInWildMode):
pass
scrape = scrape_me(url_path=url)
except WebsiteNotImplementedError:
try:
scrape = scrape_me(url_path=url, wild_mode=True)
except(NoSchemaFoundInWildMode):
pass
if not scrape:
try:
parse_list.append(remove_graph(json.loads(text)))