commit aff416edbce126a2c1f59f2b66c5e654c277b229 Author: tukaunu Date: Wed Jan 14 12:22:12 2026 +0100 initial commit diff --git a/main.py b/main.py new file mode 100644 index 0000000..1f2985c --- /dev/null +++ b/main.py @@ -0,0 +1,34 @@ +from bs4 import BeautifulSoup +import requests +from PIL import Image +from io import BytesIO + +def get_image(html): + # get the links + soup = BeautifulSoup(html, "lxml") + links = [] + for element in soup.find_all("img", attrs={"draggable": "true"}): + src = element.get("src") + if "media" in src: + links.append(src.replace("&", "&")) + + # get the images + images = [Image.open(BytesIO(requests.get(link).content)) for link in links] + + # stitch the images together + w = images[0].width + h = images[0].height + out = Image.new(mode=images[0].mode, size=(w, h * 4)) + + for i, image in enumerate(images): + out.paste(image, box=(0, h * i)) + + # done + return out + +def main(): + with open("input") as f: + get_image(f.read().strip()).save("result.png") + +if __name__ == "__main__": + main()