mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-06 14:48:02 -05:00
add user-agent to URL import html request
This commit is contained in:
@@ -1436,7 +1436,10 @@ class RecipeUrlImportView(APIView):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if validators.url(url, public=True):
|
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)
|
scrape = scrape_html(org_url=url, html=html, supported_only=False)
|
||||||
else:
|
else:
|
||||||
return Response({'error': True, 'msg': _('Invalid Url')}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': True, 'msg': _('Invalid Url')}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|||||||
Reference in New Issue
Block a user