From aa9e3672c348aebc53e301722df76c5f2d7d662e Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sat, 20 Jul 2019 15:06:56 -0400 Subject: [PATCH] Package up conversations into its own type now --- deletefb/tools/conversations.py | 17 +++++++++++++++-- deletefb/types.py | 3 +-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/deletefb/tools/conversations.py b/deletefb/tools/conversations.py index 7ea3ee5..fb4a992 100644 --- a/deletefb/tools/conversations.py +++ b/deletefb/tools/conversations.py @@ -28,12 +28,23 @@ def get_conversations(driver): while True: for convo in driver.find_elements_by_xpath("//a"): url = convo.get_attribute("href") + timestamp = None + if url and "messages/read" in url: try: - print(parse_ts(convo.find_element_by_xpath("../../..//abbr").text)) + timestamp = parse_ts(convo.find_element_by_xpath("../../..//abbr").text) except ParserError: print("Failed to parse timestamp") continue + + conversation_name = convo.find_element_by_xpath("../../../div/div/header/h3").text.strip() + + assert(conversation_name) + assert(url) + + yield Conversation(url=url, + name=conversation_name, + timestamp=timestamp) try: next_url = (driver.find_element_by_id("see_older_threads"). find_element_by_xpath("a"). @@ -55,4 +66,6 @@ def delete_conversations(driver): convos = list(get_conversations(driver)) for convo in convos: - driver.get(convo) + print(convo.url) + print(convo.name) + print(convo.timestamp) diff --git a/deletefb/types.py b/deletefb/types.py index 429f3ba..3d0c2c4 100644 --- a/deletefb/types.py +++ b/deletefb/types.py @@ -26,9 +26,8 @@ class Comment: @attr.s class Conversation: url = attr.ib() - recipient = attr.ib() name = attr.ib() - last_message_time = attr.ib(factory=timestamp_now) + timestamp = attr.ib(default=None) @attr.s class Page: