commit
e2915dde55
@ -1,13 +1,14 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
from json import JSONDecodeError
|
||||||
|
from urllib.parse import unquote
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from bs4.element import Tag
|
from bs4.element import Tag
|
||||||
|
from recipe_scrapers._utils import get_host_name, normalize_string
|
||||||
|
|
||||||
from cookbook.helper import recipe_url_import as helper
|
from cookbook.helper import recipe_url_import as helper
|
||||||
from cookbook.helper.scrapers.scrapers import text_scraper
|
from cookbook.helper.scrapers.scrapers import text_scraper
|
||||||
from json import JSONDecodeError
|
|
||||||
from recipe_scrapers._utils import get_host_name, normalize_string
|
|
||||||
from urllib.parse import unquote
|
|
||||||
|
|
||||||
|
|
||||||
def get_recipe_from_source(text, url, request):
|
def get_recipe_from_source(text, url, request):
|
||||||
@ -58,7 +59,7 @@ def get_recipe_from_source(text, url, request):
|
|||||||
return kid_list
|
return kid_list
|
||||||
|
|
||||||
recipe_json = {
|
recipe_json = {
|
||||||
'name': '',
|
'name': '',
|
||||||
'url': '',
|
'url': '',
|
||||||
'description': '',
|
'description': '',
|
||||||
'image': '',
|
'image': '',
|
||||||
@ -188,6 +189,6 @@ def remove_graph(el):
|
|||||||
for x in el['@graph']:
|
for x in el['@graph']:
|
||||||
if '@type' in x and x['@type'] == 'Recipe':
|
if '@type' in x and x['@type'] == 'Recipe':
|
||||||
el = x
|
el = x
|
||||||
except TypeError:
|
except (TypeError, JSONDecodeError):
|
||||||
pass
|
pass
|
||||||
return el
|
return el
|
||||||
|
Loading…
Reference in New Issue
Block a user