use urljoin instead for the image url
All checks were successful
Build napotd / Build-And-Push (push) Successful in 23s

This commit is contained in:
2024-03-14 20:03:40 -05:00
parent 09cc9dba58
commit 6e85a8fa09

View File

@@ -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: