added a semi functional scraper

it needs to be in a country that doesn't have age verification to work (like the US or japan), or a twitter account that's verified
This commit is contained in:
2026-01-14 13:08:06 +01:00
parent aff416edbc
commit cb82711633
5 changed files with 66 additions and 32 deletions

39
main.py
View File

@@ -1,34 +1,9 @@
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")
from stitch import get_image
from scrape import get_page
if __name__ == "__main__":
main()
url = ""
source = get_page(url)
image = get_image(source)
image.save("result.png")