Add heathcliff scraping code

This commit is contained in:
June 2025-10-14 19:53:32 +13:00
parent 997aaa4984
commit ef0a97589e
2 changed files with 19 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
.venv .venv
.env .env
**/.DS_Store **/.DS_Store
__pycache__

17
main.py
View File

@ -1 +1,18 @@
from urllib import request 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