Browse Source

force url to mobile site for deleting wall posts (#130)

* force url to mobile site for deleting wall posts

* use urlunparse to force to mobile instead
pull/134/head v.1.1.15
Wesley Kerfoot 4 years ago
committed by GitHub
parent
commit
5830cfeecd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      deletefb/tools/common.py
  2. 4
      deletefb/tools/wall.py

12
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,17 @@ 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)
return urlparse.urlunparse((parsed.scheme,
"mobile.facebook.com",
parsed.path,
parsed.params,
parsed.query,
parsed.fragment))
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