وضع علامة على المشاركات في الموضوع كـ "مقروءة"

لقد حاولت إجراء هندسة عكسية للموقع عن طريق إرسال طلبات POST إلى “https://{hostUrl}/topics/timings” مع محتوى-النوع (content-type) ورمز الحماية من التزييف (csrf token) وعامل المستخدم (user-agent).

يبدو جسم الطلب (json) كما يلي:

payload = {
  "topic_id": topic_id,
  "topic_time": post_count * 60000,
  "timings": timings
}

يعيد رمز حالة 200 ولكن سجل القراءة لا يتغير أبدًا على https://{hostUrl}/u/USERNAME/activity/read

لقد حاولت البحث في هذا المنشور ولكنه لم يكن مفيدًا جدًا:

إليك جزء كبير من الكود:

def get_csrf(session):
    r = session.get(f"https://{hostUrl}/session/csrf.json")

    if r.status_code != 200:
        raise RuntimeError("فشل في الحصول على CSRF")

    data = r.json()

    if "csrf" not in data:
        raise RuntimeError("لا يوجد CSRF في الاستجابة")

    return data["csrf"]

def load_topics(session, page):
    print(f"[المواضيع] الصفحة {page}")

    r = session.get(
        f"https://{hostUrl}/latest.json?page={page}"
    )

    if r.status_code != 200:
        return []

    data = r.json()

    return [
        {
            "id": t["id"],
            "posts_count": t["posts_count"]
        }
        for t in data["topic_list"]["topics"]
    ]

def mark_post_as_read(session, topic_id, post_count):
    url = f"https://{hostUrl}/topics/timings"

    timings = {
        str(i): 60000
        for i in range(1, post_count + 1)
    }

    payload = {
        "topic_id": topic_id,
        "topic_time": post_count * 60000,
        "timings": timings
    }

    csrf = get_csrf(session)

    r = session.post(
        url,
        json=payload,
        headers={
            "X-CSRF-Token": csrf,
            "User-Agent": "Mozilla/5.0",
            "Content-Type": "application/json"
        }
    )

    print(f"[قراءة] {topic_id} → {r.status_code}")

    if r.status_code != 200:
        print(r.text[:300])

def tab_worker(session):
    page = 1

    while True:
        topics = load_topics(session, page)

        if not topics:
            break

        for t in topics:
            mark_post_as_read(
                session,
                t["id"],
                t["posts_count"]
            )

            time.sleep(0.4)

        page += 1