diff options
author | garret <garret@airmail.cc> | 2024-07-02 18:15:59 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2024-07-02 18:24:37 +0100 |
commit | d68b1760adcd20d1d2f8c5377f860849fc9bf304 (patch) | |
tree | 84200b9b1fd4e78b9e253eab34f95b52f22eaf65 /fetch-status.py | |
parent | e7b3f87211253fd7b98ddaddc05a364890415f6b (diff) | |
download | agora-status-d68b1760adcd20d1d2f8c5377f860849fc9bf304.tar.gz agora-status-d68b1760adcd20d1d2f8c5377f860849fc9bf304.tar.bz2 agora-status-d68b1760adcd20d1d2f8c5377f860849fc9bf304.zip |
only accept posts actually by the user
so people cant just go and vandalise peoples sites by posting on their page
a
Diffstat (limited to 'fetch-status.py')
-rwxr-xr-x | fetch-status.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/fetch-status.py b/fetch-status.py index 88e3bb7..9cb4be3 100755 --- a/fetch-status.py +++ b/fetch-status.py @@ -30,14 +30,27 @@ headers = { profile_html = requests.get("https://forum.agoraroad.com/index.php?members/" + profile_id, headers=headers).text soup = BeautifulSoup(profile_html, 'lxml') -profile_post = soup.find("div", attrs={ - "class": "lbContainer js-lbContainer", - "data-lb-id": re.compile(r"profile\-post\-\d+") -}) +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 profile_post is None: +if post_body is None: print("Content-Type: text/plain; charset=utf-8") if is_loginwall: print("Status: 403") @@ -52,9 +65,9 @@ if profile_post is None: else: print("Status: 500") print() - print("it didn't work for some reason, possibly you don't have any posts on your profile") + 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(profile_post) +print(post_body) |