From 6b9db956377f57c51bddcb8cac784e8be3c6b610 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 10 Sep 2019 14:12:47 -0400 Subject: [PATCH] monitoring tweaks + bug fixes --- chan/fchan_html.py | 2 ++ chan/tgchan_html.py | 2 ++ util.py | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/chan/fchan_html.py b/chan/fchan_html.py index 33a424b..cb0128a 100644 --- a/chan/fchan_html.py +++ b/chan/fchan_html.py @@ -15,8 +15,10 @@ class FChanHtmlChanHelper(DesuChanHtmlChanHelper): threads = [] for threadEl in soup.find_all("div", id=lambda tid: tid and re.match("thread[0-9]+", tid)): + omit = threadEl.find("span", class_="omittedposts") threads.append({ "id": int(threadEl.get("id")[6:]), + "omit": int(omit.text.split(" ")[0]) if omit and omit.text else 0 }) next_url = None diff --git a/chan/tgchan_html.py b/chan/tgchan_html.py index 58a41cb..04e6a20 100644 --- a/chan/tgchan_html.py +++ b/chan/tgchan_html.py @@ -15,8 +15,10 @@ class TgChanHtmlChanHelper(DesuChanHtmlChanHelper): threads = [] for threadEl in soup.find_all("div", id=lambda tid: tid and tid[6:7].isdigit()): + omit = threadEl.find("span", class_="omittedposts") threads.append({ "id": int(re.search("thread([0-9]+)[a-zA-Z]*", threadEl.get("id")).group(1)), + "omit": int(omit.text.split(" ")[0]) if omit else 0 }) for form in soup.find_all("form"): diff --git a/util.py b/util.py index b8f4802..cd7d30a 100644 --- a/util.py +++ b/util.py @@ -63,7 +63,8 @@ class Web: "measurement": "web", "time": str(datetime.utcnow()), "fields": { - "status_code": r.status_code + "status_code": r.status_code, + "size": len(r.content), }, "tags": { "ok": r.status_code == 200 @@ -77,7 +78,8 @@ class Web: "measurement": "web", "time": str(datetime.utcnow()), "fields": { - "status_code": 0 + "status_code": 0, + "size": 0, }, "tags": { "ok": False