Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
force url to mobile site for deleting wall posts (#130)
Browse files Browse the repository at this point in the history
* force url to mobile site for deleting wall posts

* use urlunparse to force to mobile instead
  • Loading branch information
weskerfoot authored Sep 8, 2020
1 parent 1875b75 commit 5830cfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions deletefb/tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging
import logging.config
import os
import urllib.parse as urlparse

SELENIUM_EXCEPTIONS = (
NoSuchElementException,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion deletefb/tools/wall.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down

0 comments on commit 5830cfe

Please sign in to comment.