#!/usr/bin/env python3 import re from bs4 import BeautifulSoup import requests import os print("Access-Control-Allow-Origin: *") # CORS shit, needed for styling iframes apparently profile_id = os.environ['QUERY_STRING'].strip() if not profile_id.isdigit(): print("Status: 400 Bad Request") print("Content-Type: text/plain") print() current_url = "https://" if os.environ.get("HTTPS") else "http://" current_url += os.environ.get("HTTP_HOST") + os.environ.get("REQUEST_URI") if current_url.endswith("?"+profile_id): current_url = current_url[:-len(profile_id)-1] print(f"you have to put your user id as a query, like {current_url}?6498") quit() headers = { 'User-Agent': f'agora status fetcher - contact forum user "garret 427738" or https://427738.xyz/hate-mail.html - requested by {os.environ.get("REMOTE_ADDR")}', } profile_html = requests.get("https://forum.agoraroad.com/index.php?members/" + profile_id, headers=headers).text soup = BeautifulSoup(profile_html, 'lxml') posts = soup.find_all("div", class_="message-content js-messageContent") post_body = None for post in posts: posted_by_user = post.find("a", attrs={ "class": 'username', "data-user-id": profile_id, }) != None if posted_by_user: post_body = post.find("div", attrs={ "class": "lbContainer js-lbContainer", "data-lb-id": re.compile(r"profile\-post\-\d+") }) break is_loginwall = soup.find("html", class_='has-no-js template-login') != None is_cloudflare_block = soup.find("title").text == "Just a moment..." if post_body is None: print("Content-Type: text/plain; charset=utf-8") if is_loginwall: print("Status: 403") print() print("🚨🚨🚨 schizo alert! 🚨🚨🚨") print("it won't work if you don't expose your profile to the public, sorry") elif is_cloudflare_block: print("status: 403") print() print("blocked by cloudflare :(") print("i've found it to work from my home ip, probably this is hosted on a datacentre one...") else: print("Status: 500") print() print("it didn't work for some reason, possibly you've not made any posts on your profile") quit() print("Content-Type: text/html; charset=utf-8") print() print(post_body)