Squashed commit of the following:
commit 707d862e01a7497a1f22879d314b865a35e0e85b
Author: smilerz <smilerz@gmail.com>
Date: Wed Apr 14 10:35:00 2021 -0500
works now
commit 3942a445ed4f2ccec57de25eacd86ea4e4dd6bdb
Author: smilerz <smilerz@gmail.com>
Date: Wed Apr 14 10:25:24 2021 -0500
updated serializer and api
commit 10dc746eb175c7f805a8a8ffa7ce49977a7ce97e
Author: smilerz <smilerz@gmail.com>
Date: Wed Apr 14 10:20:19 2021 -0500
fixed bookmarklet
commit 9779104902d3be0258c95cd2eeebcba0d5d48892
Merge: bb8262c 0cb3928
Author: smilerz <smilerz@gmail.com>
Date: Wed Apr 14 09:56:27 2021 -0500
Merge branch 'bookmarklet' into json_import
commit 0cb39284bb835ffc6cfee3e4306aadc4a64a25be
Author: smilerz <smilerz@gmail.com>
Date: Wed Apr 14 09:42:53 2021 -0500
retrieve bookmarklet ID from get
commit e89e0218de684d40b2e2bfb6ba833891206c828e
Author: smilerz <smilerz@gmail.com>
Date: Wed Apr 14 09:29:33 2021 -0500
Revert "fixed broken tab"
This reverts commit ca0a1aede3cc6cb3912bc1fe30c0aa22e3f481a6.
commit bb8262ccabb93c56fbc18c407d5a0653b8b3ca79
Merge: b1e73aa 35a7f62
Author: smilerz <smilerz@gmail.com>
Date: Sun Apr 11 20:35:57 2021 -0500
Merge branch 'main_fork' into json_import
This commit is contained in:
@ -73,9 +73,11 @@ def get_recipe_from_source(text, url, space):
|
||||
html_data = []
|
||||
images = []
|
||||
|
||||
# text = normalize_string(text)
|
||||
try:
|
||||
parse_list.append(remove_graph(json.loads(text)))
|
||||
if not url and 'url' in parse_list[0]:
|
||||
url = parse_list[0]['url']
|
||||
scrape = text_scraper("<script type='application/ld+json'>" + text + "</script>", url=url)
|
||||
|
||||
except JSONDecodeError:
|
||||
soup = BeautifulSoup(text, "html.parser")
|
||||
@ -83,6 +85,8 @@ def get_recipe_from_source(text, url, space):
|
||||
images += get_images_from_source(soup, url)
|
||||
for el in soup.find_all('script', type='application/ld+json'):
|
||||
el = remove_graph(el)
|
||||
if not url and 'url' in el:
|
||||
url = el['url']
|
||||
if type(el) == list:
|
||||
for le in el:
|
||||
parse_list.append(le)
|
||||
@ -95,15 +99,6 @@ def get_recipe_from_source(text, url, space):
|
||||
parse_list.append(le)
|
||||
elif type(el) == dict:
|
||||
parse_list.append(el)
|
||||
|
||||
# if a url was not provided, try to find one in the first document
|
||||
if not url and len(parse_list) > 0:
|
||||
if 'url' in parse_list[0]:
|
||||
url = parse_list[0]['url']
|
||||
|
||||
if type(text) == dict:
|
||||
scrape = text_scraper("<script type='application/ld+json'>" + text + "</script>", url=url)
|
||||
elif type(text) == str:
|
||||
scrape = text_scraper(text, url=url)
|
||||
|
||||
recipe_json = helper.get_from_scraper(scrape, space)
|
||||
|
Reference in New Issue
Block a user