From b095718545f08316c80a9077d3ff888883399c17 Mon Sep 17 00:00:00 2001 From: smilerz Date: Tue, 30 Jul 2024 14:03:12 -0500 Subject: [PATCH] add user-agent to URL import html request --- cookbook/views/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 734e5333b..4ed6a07a1 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -1436,7 +1436,10 @@ class RecipeUrlImportView(APIView): else: try: if validators.url(url, public=True): - html = requests.get(url).content + html = requests.get( + url, + headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0"} + ).content scrape = scrape_html(org_url=url, html=html, supported_only=False) else: return Response({'error': True, 'msg': _('Invalid Url')}, status=status.HTTP_400_BAD_REQUEST)