bookmarklet passing data to form

This commit is contained in:
smilerz
2021-03-25 17:48:32 -05:00
parent 09d2e9f831
commit f80c44bca3
8 changed files with 434 additions and 28 deletions

View File

@ -72,6 +72,7 @@ def get_recipe_from_source(text, url, space):
html_data = []
images = []
text = normalize_string(text)
try:
parse_list.append(remove_graph(json.loads(text)))
except JSONDecodeError:
@ -83,13 +84,12 @@ def get_recipe_from_source(text, url, space):
for el in soup.find_all(type='application/json'):
parse_list.append(remove_graph(el))
# if a url was not provided, try to find one in the first document
if not url:
if 'url' in parse_list[0]:
url = parse_list[0]['url']
# first try finding ld+json as its most common
for el in parse_list:
# if a url was not provided, try to find one in the first document
if not url:
if 'url' in el:
url = el['url']
if isinstance(el, Tag):
try: