|
@ -26,21 +26,35 @@ def delete_posts(driver, |
|
|
|
|
|
|
|
|
driver.get(user_profile_url) |
|
|
driver.get(user_profile_url) |
|
|
|
|
|
|
|
|
|
|
|
finished = False |
|
|
|
|
|
|
|
|
|
|
|
with archiver("wall") as archive_wall_post: |
|
|
for _ in range(MAX_POSTS): |
|
|
for _ in range(MAX_POSTS): |
|
|
post_button_sel = "_4xev" |
|
|
if finished: |
|
|
|
|
|
break |
|
|
|
|
|
post_button_sel = "_4s19" |
|
|
|
|
|
|
|
|
post_content_sel = "userContent" |
|
|
post_content_sel = "userContent" |
|
|
post_timestamp_sel = "timestampContent" |
|
|
post_timestamp_sel = "timestampContent" |
|
|
|
|
|
|
|
|
button_types = ["FeedDeleteOption", "HIDE_FROM_TIMELINE", "UNTAG"] |
|
|
confirmation_button_exp = "//div[contains(@data-sigil, 'undo-content')]//*/a[contains(@href, 'direct_action_execute')]" |
|
|
|
|
|
|
|
|
|
|
|
button_types = ["Delete post", "Remove Tag", "Hide from timeline"] |
|
|
|
|
|
|
|
|
with archiver("wall") as archive_wall_post: |
|
|
|
|
|
while True: |
|
|
while True: |
|
|
try: |
|
|
try: |
|
|
timeline_element = driver.find_element_by_class_name(post_button_sel) |
|
|
try: |
|
|
|
|
|
timeline_element = driver.find_element_by_xpath("//div[@data-sigil='story-popup-causal-init']/a") |
|
|
|
|
|
except SELENIUM_EXCEPTIONS: |
|
|
|
|
|
print("Could not find any posts") |
|
|
|
|
|
finished = True |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
post_content_element = driver.find_element_by_xpath("//article/div[@class='story_body_container']/div") |
|
|
|
|
|
post_content_ts = driver.find_element_by_xpath("//article//*/header//a[contains(@href, 'story')]") |
|
|
|
|
|
|
|
|
post_content_element = driver.find_element_by_class_name(post_content_sel) |
|
|
if not (post_content_element or post_content_ts): |
|
|
post_content_ts = driver.find_element_by_class_name(post_timestamp_sel) |
|
|
break |
|
|
|
|
|
|
|
|
# Archive the post |
|
|
# Archive the post |
|
|
archive_wall_post.archive( |
|
|
archive_wall_post.archive( |
|
@ -53,15 +67,15 @@ def delete_posts(driver, |
|
|
actions = ActionChains(driver) |
|
|
actions = ActionChains(driver) |
|
|
actions.move_to_element(timeline_element).click().perform() |
|
|
actions.move_to_element(timeline_element).click().perform() |
|
|
|
|
|
|
|
|
wait_xpath(driver, "//*[@id='feed_post_menu']/..") |
|
|
wait_xpath(driver, "//*[contains(@data-sigil, 'removeStoryButton')]") |
|
|
|
|
|
|
|
|
menu = driver.find_element_by_xpath("//*[@id='feed_post_menu']/..") |
|
|
|
|
|
|
|
|
|
|
|
delete_button = None |
|
|
delete_button = None |
|
|
|
|
|
|
|
|
for button_type in button_types: |
|
|
for button_type in button_types: |
|
|
try: |
|
|
try: |
|
|
delete_button = menu.find_element_by_xpath("//a[@data-feed-option-name=\"{0}\"]".format(button_type)) |
|
|
delete_button = driver.find_element_by_xpath("//*[text()='{0}']".format(button_type)) |
|
|
|
|
|
if not delete_button.is_displayed(): |
|
|
|
|
|
continue |
|
|
break |
|
|
break |
|
|
except SELENIUM_EXCEPTIONS as e: |
|
|
except SELENIUM_EXCEPTIONS as e: |
|
|
print(e) |
|
|
print(e) |
|
@ -72,8 +86,10 @@ def delete_posts(driver, |
|
|
break |
|
|
break |
|
|
|
|
|
|
|
|
click_button(driver, delete_button) |
|
|
click_button(driver, delete_button) |
|
|
confirmation_button = driver.find_element_by_class_name("layerConfirm") |
|
|
wait_xpath(driver, confirmation_button_exp) |
|
|
|
|
|
confirmation_button = driver.find_element_by_xpath(confirmation_button_exp) |
|
|
|
|
|
|
|
|
|
|
|
print(confirmation_button) |
|
|
click_button(driver, confirmation_button) |
|
|
click_button(driver, confirmation_button) |
|
|
|
|
|
|
|
|
except SELENIUM_EXCEPTIONS as e: |
|
|
except SELENIUM_EXCEPTIONS as e: |
|
|