Browse Source

Package up conversations into its own type now

pull/72/head
Wesley Kerfoot 5 years ago
parent
commit
aa9e3672c3
  1. 17
      deletefb/tools/conversations.py
  2. 3
      deletefb/types.py

17
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)

3
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:

Loading…
Cancel
Save