Browse Source

force url to mobile site for deleting wall posts

pull/130/head
wes 4 years ago
parent
commit
34895a2518
  1. 9
      deletefb/tools/common.py
  2. 4
      deletefb/tools/wall.py

9
deletefb/tools/common.py

@ -12,6 +12,7 @@ import json
import logging
import logging.config
import os
import urllib.parse as urlparse
SELENIUM_EXCEPTIONS = (
NoSuchElementException,
@ -67,6 +68,14 @@ def wait_xpath(driver, expr):
except SELENIUM_EXCEPTIONS:
return
def force_mobile(url):
"""
Force a url to use the mobile site.
"""
parsed = urlparse.urlparse(url)
if parsed.netloc == "www.facebook.com":
return f"https://mobile.facebook.com{parsed.path}"
return url
NO_CHROME_DRIVER = """
You need to manually install the chromedriver for Selenium\n

4
deletefb/tools/wall.py

@ -1,6 +1,6 @@
from ..types import Post
from .archive import archiver
from .common import SELENIUM_EXCEPTIONS, click_button, wait_xpath
from .common import SELENIUM_EXCEPTIONS, click_button, wait_xpath, force_mobile
from .config import settings
from selenium.webdriver.common.action_chains import ActionChains
@ -24,6 +24,8 @@ def delete_posts(driver,
if year is not None:
user_profile_url = "{0}/timeline?year={1}".format(user_profile_url, year)
user_profile_url = force_mobile(user_profile_url)
driver.get(user_profile_url)
finished = False

Loading…
Cancel
Save