|
@ -1,9 +1,10 @@ |
|
|
import time |
|
|
import time |
|
|
|
|
|
|
|
|
from selenium.webdriver.common.action_chains import ActionChains |
|
|
from selenium.webdriver.common.action_chains import ActionChains |
|
|
from .common import SELENIUM_EXCEPTIONS |
|
|
from .common import SELENIUM_EXCEPTIONS, archiver |
|
|
|
|
|
|
|
|
MAX_POSTS = 5000 |
|
|
# Used as a threshold to avoid running forever |
|
|
|
|
|
MAX_POSTS = 15000 |
|
|
|
|
|
|
|
|
def delete_posts(driver, |
|
|
def delete_posts(driver, |
|
|
user_profile_url, |
|
|
user_profile_url, |
|
@ -17,12 +18,23 @@ def delete_posts(driver, |
|
|
|
|
|
|
|
|
driver.get(user_profile_url) |
|
|
driver.get(user_profile_url) |
|
|
|
|
|
|
|
|
|
|
|
wall_log, archive_wall_post = archiver("wall") |
|
|
|
|
|
|
|
|
for _ in range(MAX_POSTS): |
|
|
for _ in range(MAX_POSTS): |
|
|
post_button_sel = "_4xev" |
|
|
post_button_sel = "_4xev" |
|
|
|
|
|
post_content_sel = "_5_jv" |
|
|
|
|
|
|
|
|
|
|
|
post_timestamp_sel = "timestamp" |
|
|
|
|
|
|
|
|
while True: |
|
|
while True: |
|
|
try: |
|
|
try: |
|
|
timeline_element = driver.find_element_by_class_name(post_button_sel) |
|
|
timeline_element = driver.find_element_by_class_name(post_button_sel) |
|
|
|
|
|
|
|
|
|
|
|
post_content_element = driver.find_element_by_class_name(post_content_sel) |
|
|
|
|
|
post_content_ts = driver.find_element_by_class_name(post_timestamp_sel) |
|
|
|
|
|
|
|
|
|
|
|
archive_wall_post(post_content_element.text, timestamp=post_content_ts.text) |
|
|
|
|
|
|
|
|
actions = ActionChains(driver) |
|
|
actions = ActionChains(driver) |
|
|
actions.move_to_element(timeline_element).click().perform() |
|
|
actions.move_to_element(timeline_element).click().perform() |
|
|
|
|
|
|
|
|