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
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
15 additions and
1 deletions
-
deletefb/tools/common.py
-
deletefb/tools/wall.py
|
@ -12,6 +12,7 @@ import json |
|
|
import logging |
|
|
import logging |
|
|
import logging.config |
|
|
import logging.config |
|
|
import os |
|
|
import os |
|
|
|
|
|
import urllib.parse as urlparse |
|
|
|
|
|
|
|
|
SELENIUM_EXCEPTIONS = ( |
|
|
SELENIUM_EXCEPTIONS = ( |
|
|
NoSuchElementException, |
|
|
NoSuchElementException, |
|
@ -67,6 +68,17 @@ def wait_xpath(driver, expr): |
|
|
except SELENIUM_EXCEPTIONS: |
|
|
except SELENIUM_EXCEPTIONS: |
|
|
return |
|
|
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 = """ |
|
|
NO_CHROME_DRIVER = """ |
|
|
You need to manually install the chromedriver for Selenium\n |
|
|
You need to manually install the chromedriver for Selenium\n |
|
|
|
@ -1,6 +1,6 @@ |
|
|
from ..types import Post |
|
|
from ..types import Post |
|
|
from .archive import archiver |
|
|
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 .config import settings |
|
|
from selenium.webdriver.common.action_chains import ActionChains |
|
|
from selenium.webdriver.common.action_chains import ActionChains |
|
|
|
|
|
|
|
@ -24,6 +24,8 @@ def delete_posts(driver, |
|
|
if year is not None: |
|
|
if year is not None: |
|
|
user_profile_url = "{0}/timeline?year={1}".format(user_profile_url, year) |
|
|
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) |
|
|
driver.get(user_profile_url) |
|
|
|
|
|
|
|
|
finished = False |
|
|
finished = False |
|
|