From 6e85a8fa0930cb6bd5d10881fe9dedc790f46ad3 Mon Sep 17 00:00:00 2001 From: deltreey Date: Thu, 14 Mar 2024 20:03:40 -0500 Subject: [PATCH] use urljoin instead for the image url --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index c666684..551d9f5 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +from urllib.parse import urljoin + from bs4 import BeautifulSoup from requests import get from starlette.responses import RedirectResponse @@ -17,7 +19,7 @@ def main(): soup = BeautifulSoup(html, features="html.parser") img = soup.find('img') image_url = img['src'] - return url + image_url + return urljoin(url, image_url) # with open('img.png', 'wb') as out_file: # response = get(url + image_url, stream=True) # for chunk in response: