aboutsummaryrefslogtreecommitdiffstats
path: root/fetch-status.py
diff options
context:
space:
mode:
Diffstat (limited to 'fetch-status.py')
-rwxr-xr-xfetch-status.py27
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)