This commit is contained in:
smilerz
2024-08-22 12:45:49 -05:00
parent 596b6c6f98
commit b6fa74c601
2 changed files with 5 additions and 3 deletions

View File

@@ -28,7 +28,9 @@ def get_from_scraper(scrape, request):
source_url = scrape.url
except Exception:
pass
if source_url:
if source_url == "https://urlnotfound.none" or not source_url:
recipe_json['source_url'] = ''
else:
recipe_json['source_url'] = source_url
try:
keywords.append(source_url.replace('http://', '').replace('https://', '').split('/')[0])

View File

@@ -1458,9 +1458,9 @@ class RecipeUrlImportView(APIView):
data = "<script type='application/ld+json'>" + json.dumps(data_json) + "</script>"
except JSONDecodeError:
pass
scrape = scrape_html(html=data, org_url=url, supported_only=False)
scrape = scrape_html(html=data, org_url='https://urlnotfound.none', supported_only=False)
if not url and (found_url := scrape.schema.data.get('url', 'https://urlnotfound.none')):
scrape = scrape_html(text=data, url=found_url, supported_only=False)
scrape = scrape_html(html=data, org_url=found_url, supported_only=False)
if scrape:
return Response({