mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
6.64k stars 681 forks source link

[SCRAPER] - i can't add any recipe by url #4010

Open litianyu0707 opened 1 month ago

litianyu0707 commented 1 month ago

First Check

Please provide 1-5 example URLs that are having errors

hello , i set up mealie by unraid docker market. i can't add any recipe by URL, but in the demo website i can add it normaly. image

such as: https://sallysbakingaddiction.com/lemon-sweet-rolls/

Please provide your logs for the Mealie container docker logs <container-id> > mealie.logs

recipe, extras = await create_from_url(req.url, self.translator) File "/app/mealie/services/scraper/scraper.py", line 34, in create_from_url new_recipe, extras = await scraper.scrape(url) File "/app/mealie/services/scraper/recipe_scraper.py", line 40, in scrape raw_html = await safe_scrape_html(url) File "/app/mealie/services/scraper/scraper_strategies.py", line 47, in safe_scrape_html async with client.stream( File "/usr/local/lib/python3.10/contextlib.py", line 199, in aenter return await anext(self.gen) File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1617, in stream response = await self.send( File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1661, in send response = await self._send_handling_auth( File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1689, in _send_handling_auth response = await self._send_handling_redirects( File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects response = await self._send_single_request(request) File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1763, in _send_single_request response = await transport.handle_async_request(request) File "/app/mealie/pkgs/safehttp/transport.py", line 73, in handle_async_request raise InvalidDomainError(f"invalid request on local resource: {request.url} -> {ip}") mealie.pkgs.safehttp.transport.InvalidDomainError: invalid request on local resource: https://sallysbakingaddiction.com/lemon-sweet-rolls/ -> 198.18.131.233 ERROR 2024-08-09T21:38:22 - Exception in ASGI application Traceback (most recent call last): File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 399, in run_asgi result = await app( # type: ignore[func-returns-value] File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in call return await self.app(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/applications.py", line 123, in call await self.middleware_stack(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 24, in call await responder(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 44, in call await self.app(scope, receive, self.send_with_gzip) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 65, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 756, in call await self.middleware_stack(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 776, in app await route.handle(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle await self.app(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 77, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 72, in app response = await func(request) File "/app/mealie/routes/_base/routers.py", line 35, in custom_route_handler response = await original_route_handler(request) File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 278, in app raw_response = await run_endpoint_function( File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(**values) File "/app/mealie/routes/recipe/recipe_crud_routes.py", line 203, in parse_recipe_url recipe, extras = await create_from_url(req.url, self.translator) File "/app/mealie/services/scraper/scraper.py", line 34, in create_from_url new_recipe, extras = await scraper.scrape(url) File "/app/mealie/services/scraper/recipe_scraper.py", line 40, in scrape raw_html = await safe_scrape_html(url) File "/app/mealie/services/scraper/scraper_strategies.py", line 47, in safe_scrape_html async with client.stream( File "/usr/local/lib/python3.10/contextlib.py", line 199, in aenter return await anext(self.gen) File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1617, in stream response = await self.send( File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1661, in send response = await self._send_handling_auth( File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1689, in _send_handling_auth response = await self._send_handling_redirects( File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects response = await self._send_single_request(request) File "/opt/pysetup/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1763, in _send_single_request response = await transport.handle_async_request(request) File "/app/mealie/pkgs/safehttp/transport.py", line 73, in handle_async_request raise InvalidDomainError(f"invalid request on local resource: {request.url} -> {ip}") mealie.pkgs.safehttp.transport.InvalidDomainError: invalid request on local resource: https://sallysbakingaddiction.com/lemon-sweet-rolls/ -> 198.18.131.233

Deployment

Docker (Linux)

Halfang commented 4 weeks ago

I seemed to have a similar issue with truenas scale, but I seem to have fixed it. Make sure that the docker / jail / instance can see the Internet directly. I had to enable host network on my truenas app install.

After this I was able to get it to work with your link.

Try with this one:

https://www.novachef.cat/receptes/truita-patates

Also try that link or yours on the demo site. Then try to share the recipe, and use that shared link into your installation. If that doesn't even work for you then there's something else broken, I suspect from your network interface.