use urljoin instead for the image url
All checks were successful
Build napotd / Build-And-Push (push) Successful in 23s
All checks were successful
Build napotd / Build-And-Push (push) Successful in 23s
This commit is contained in:
4
main.py
4
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:
|
||||
|
||||
Reference in New Issue
Block a user