From ef0a97589ebb0af9345b98051e4e8ccb4a726e50 Mon Sep 17 00:00:00 2001 From: June Date: Tue, 14 Oct 2025 19:53:32 +1300 Subject: [PATCH] Add heathcliff scraping code --- .gitignore | 3 ++- main.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f741989..c1d9319 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .venv .env -**/.DS_Store \ No newline at end of file +**/.DS_Store +__pycache__ \ No newline at end of file diff --git a/main.py b/main.py index 4a0fc0b..fe5e0d6 100644 --- a/main.py +++ b/main.py @@ -1 +1,18 @@ from urllib import request +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/") +def read_root(): + return get_cliff() + + +def get_cliff(): + r = request.Request('https://www.creators.com/read/heathcliff', headers={'User-Agent': 'Mozilla/5.0'}) + html = request.urlopen(r).read().decode("utf8") + + urlStart = html.index('https://cdn.alphacomedy.com') + imageUrl = html[urlStart:].split("\"")[0] + + return imageUrl \ No newline at end of file